import math def my_abs(x): if x > 0: return x else: return -x print(my_abs(-6)) #ax^2+bx+c=0 def quadratic(a,b,c,): t = b*b-4*a*c if a==0&b!=0: x=-(b/c) return x elif a!=0: if t>0: x1 = (-b+math.sqrt(t))/(2*a) x2 = (-b-math.sqrt(t))/(2*a) return x1,x2 elif t==0: x=-b/(2*a) return x else: print‘wujie‘ print(quadratic(2,3,1))
时间: 2024-10-25 21:50:21