Python指数运算

adam-ma / 2024-02-18 / 原文

Python指数运算

  1. 指数大于1,如求xn次方

    pow(x, n)
    
  2. 指数小于1,这里要求底数必须大于0,即x > 0,如求x的平方根:

    import math
    math.sqrt(x)
    

    或者:

    pow(x, 1/2)