import math def quadratic(a,b,c): M = bb - 4ac if M>0: x1 = (-b+math.sqrt(M))/(2a) x2 = (-b-math.sqrt(M))/(2a) return x1,x2 elif M==0: x1 = x2 = (-b)/(2a) return x1,x2 else: return 'none' print(quadratic(2, 3, 1)) (-0.5, -1.0) print(quadratic(1, 3, -4)) (1.0, -4.0)
import math def quadratic(a,b,c): M = bb - 4ac if M>0: x1 = (-b+math.sqrt(M))/(2a) x2 = (-b-math.sqrt(M))/(2a) return x1,x2 elif M==0: x1 = x2 = (-b)/(2a) return x1,x2 else: return 'none'
print(quadratic(2, 3, 1)) (-0.5, -1.0) print(quadratic(1, 3, -4)) (1.0, -4.0)
Sign in to make a reply
冒泡的大狸猫