您现在的位置是:主页 > news > 福州网站建设服务/宽带业务如何推广
福州网站建设服务/宽带业务如何推广
admin2025/5/5 0:01:03【news】
简介福州网站建设服务,宽带业务如何推广,王爷奴家减个肥,怎么制作文件Decimal#sqrt():sqrt()是一个Decimal类方法,该方法将非负数的平方根返回上下文精度。用法:Decimal.sqrt()参数:十进制值返回:非负数的平方根到上下文精度。代码1:sqrt()方法示例# Python Progra…
Decimal#sqrt():sqrt()是一个Decimal类方法,该方法将非负数的平方根返回上下文精度。
用法:Decimal.sqrt()
参数:十进制值
返回:非负数的平方根到上下文精度。
代码1:sqrt()方法示例
# Python Program explaining
# sqrt() method
# loading decimal library
from decimal import *
# Initializing a decimal value
a = Decimal(1)
b = Decimal(2)
# printing Decimal values
print ("Decimal value a : ", a)
print ("Decimal value b : ", b)
# Using Decimal.sqrt() method
print ("\n\nDecimal a with sqrt() method : ", a.sqrt())
print ("Decimal b with sqrt() method : ", b.sqrt())
输出:
Decimal value a : 1
Decimal value b : 2
Decimal a with sqrt() method : 1
Decimal b with sqrt() method : 1.414213562373095048801688724
代码2:sqrt()方法的示例
# Python Program explaining
# sqrt() method
# loading decimal library
from decimal import *
# Initializing a decimal value
a = Decimal(300)
b = Decimal(15)
# printing Decimal values
print ("Decimal value a : ", a)
print ("Decimal value b : ", b)
# Using Decimal.sqrt() method
print ("\n\nDecimal a with sqrt() method : ", a.sqrt())
print ("Decimal b with sqrt() method : ", b.sqrt())
输出:
Decimal value a : 300
Decimal value b : 15
Decimal a with sqrt() method : 17.32050807568877293527446342
Decimal b with sqrt() method : 3.872983346207416885179265400