Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #To calculate the roots of a quadratic equation
- # a*(x^2) + b*x + c
- a = int(input('Coefficient of x^2: '))
- b = int(input('Coefficient of x: '))
- c = int(input('Product of roots: '))
- x1 = (-b + (b**2 - 4*a*c)**(1/2)) / 2 * a
- x2 = (-b - (b**2 - 4*a*c)**(1/2)) / 2 * a
- print('x1 = ' + str(x1))
- print('x2 = ' + str(x2))
- print('The roots of the quadratic equation are ' + str(x1) +' and '+ str(x2) +' respectively.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement