+ 1

Does anyone know how to fix this quadratic formula:

a=int(input()) b=int(input()) c=int(input()) print((-b+sqrt((b**2)-4*a*c))/2*a) print((-b-sqrt((b**2)-4*a*c))/2*a)

15th Mar 2022, 11:55 AM
Gonçalo Vicente
4 odpowiedzi
+ 3
You need to import math module for sqrt() method to work. import math print(math.sqrt(9))
15th Mar 2022, 12:03 PM
Simba
Simba - avatar
+ 2
Because of the operators precedence. Add this .../(2*a))
15th Mar 2022, 12:18 PM
Simba
Simba - avatar
+ 2
Thank you
15th Mar 2022, 12:54 PM
Gonçalo Vicente
+ 1
Simba that worked but it's giving me wrong values, do you know why?
15th Mar 2022, 12:06 PM
Gonçalo Vicente