Created
February 28, 2023 12:11
-
-
Save DevLord-Avijit/4c74e5c5f1ff1246c27ab86414e4e0f7 to your computer and use it in GitHub Desktop.
Python program to find out Quadratic equation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Solve the quadratic equation ax**2 + bx + c = 0 | |
| # import complex math module | |
| import cmath | |
| a = 1 | |
| b = 5 | |
| c = 6 | |
| # calculate the discriminant | |
| d = (b**2) - (4*a*c) | |
| # find two solutions | |
| sol1 = (-b-cmath.sqrt(d))/(2*a) | |
| sol2 = (-b+cmath.sqrt(d))/(2*a) | |
| print('The solution are {0} and {1}'.format(sol1,sol2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment