正在加载图片...
编程例:quadratic.py import math def main ( a,b,c input("Enter three coefficients:" discRoot math.sqrt(b*b -4*a*c) r1 (-b discRoot)/(2 a) r2 (-b discRoot)/(2 a) print WThe solutions are:"r1,r2 -用到math.sgrt()函数 -小测验:不用sqrt0能求平方根吗? 人库函数一般效率高 Lu Chaojun,SJTU 6编程例:quadratic.py import math def main() a, b, c = input(“Enter three coefficients: ”) discRoot = math.sqrt(b*b – 4*a*c) r1 = (-b + discRoot) / (2 * a) r2 = (-b – discRoot) / (2 * a) print “The solutions are:” , r1, r2 – 用到math.sqrt()函数 – 小测验:不用sqrt()能求平方根吗? ©库函数一般效率高. Lu Chaojun, SJTU 6
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有