尧图建网站 尧图建网站 YAOTU WEB BUILD 免费咨询
ARTICLE DETAIL

资讯详情

深耕网站建设与建站编程的一线实战洞察。

Python实例1 计算平方根

Python实例1 计算平方根 #codingutf-8 #filename:test1.py #计算正数平方根 nonefloat(input(输入第一个数字)) ntwonone**0.5 print(%0.3f的平方根是%0.6f%(none,ntwo))运行结果#codingutf-8 #filename:test1.py #计算负数及复数平方根 #导入复数数学模块 import cmath none float(input(请输入一个数字: )) none_sqrt cmath.sqrt(none) print({0} 的平方根为 {1:0.3f}{2:0.3f}j.format(none ,none_sqrt.real,none_sqrt.imag))运行结果
返回列表