首頁>Club>
5
回覆列表
  • 1 # 使用者834195712159

    sqrt是什麼函式?

    sqrt()是用於計算數字x的平方根的函式。

    語法

    以下是 sqrt() 方法的語法:import math

    math.sqrt( x )

    注意:sqrt()是不能直接訪問的,需要匯入 math 模組,透過靜態物件呼叫該方法。

    引數

    x -- 數值表示式。

    返回值

    返回數字x的平方根。

    例項

    以下展示了使用 sqrt() 方法的例項:#!/usr/bin/python

    import math # This will import math module

    print "math.sqrt(100) : ", math.sqrt(100)

    print "math.sqrt(7) : ", math.sqrt(7)

    print "math.sqrt(math.pi) : ", math.sqrt(math.pi)

    以上例項執行後輸出結果為:math.sqrt(100) : 10.0

    math.sqrt(7) : 2.64575131106

    math.sqrt(math.pi) : 1.77245385091

  • 中秋節和大豐收的關聯?
  • 除地溝油最快的方法?