Advertisement
Abiala

assignment4

Mar 28th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. #To calculate the roots of a quadratic equation
  2. # a*(x^2) + b*x + c
  3. a = int(input('Coefficient of x^2: '))
  4. b = int(input('Coefficient of x: '))
  5. c = int(input('Product of roots: '))
  6. x1 = (-b + (b**2 - 4*a*c)**(1/2)) / 2 * a
  7. x2 = (-b - (b**2 - 4*a*c)**(1/2)) / 2 * a
  8. print('x1 = ' + str(x1))
  9. print('x2 = ' + str(x2))
  10. print('The roots of the quadratic equation are ' + str(x1) +' and '+ str(x2) +' respectively.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement