编写一个 Python 程序,使用 sqrt 和 pow 函数(附带示例)查找数字的平方根。
此 Python 程序允许用户输入任何整数值。接下来,此程序使用一个名为 sqrt() 的 数学函数 来查找该数字的平方根。
import math
num = float(input(" Please Enter any numeric Value : "))
squareRoot = math.sqrt(num)
print("The Result Of {0} = {1}".format(num, squareRoot))

使用 pow() 查找数字平方根的程序
在此示例 程序 中,我们使用 pow() 函数来查找数字的平方根。请记住,√数字 = 数字½。
# Using pow function
import math
number = float(input(" Please Enter any numeric Value : "))
squareRoot = math.pow(number, 0.5)
print("The Square Root of a Given Number {0} = {1}".format(number, squareRoot))
