ETechSavvies

Untitled

Apr 29th, 2021
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. """
  2.    Written by: ETechSavvies [https://t.me/ETechSavvies] Apr 27,2021
  3.    Description: Quadratic equation solver
  4.    Copyright 2021 @ETechSavvies
  5. """
  6.  
  7.  
  8. #import complex math module
  9. import cmath
  10.  
  11. a = float(input("Enter the value of a= "))
  12. b = float(input("Enter the value of b= "))
  13. c = float(input("Enter the value of c= "))
  14.  
  15. # calculate the discriminant
  16. d = (b**2) - (4*a*c)
  17.  
  18. # Calculating the first solution
  19. sol1 = (-b-cmath.sqrt(d))/(2*a)
  20.  
  21. # Calculating the second solution
  22. sol2 = (-b+cmath.sqrt(d))/(2*a)
  23.  
  24. print('The solution of your quadratic equation are {0} and {1}'.format(sol1,sol2))
Advertisement
Add Comment
Please, Sign In to add comment