Created
September 5, 2020 14:41
This file contains 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
# Taking input from user for the equation ax2 +bx + c | |
a= float(input("Please enter the coefficient of the x2 term: ")) | |
b= float(input("Please enter the coefficient of the x term: ")) | |
c= float(input("Please enter the constant term: ")) | |
# Calculation of the roots of quadratic equation using the quadratic formula | |
import math | |
d= b**2 - 4*a*c | |
if d<0: | |
print("As the discriminant in the equation is equal to zero, it doesn't have real roots.") | |
else: | |
root1= ((-b) + math.sqrt(d))/(2*a) | |
root2= ((-b) - math.sqrt(d))/(2*a) | |
print("The roots of this quadratic equation are: ", root1, " and " , root2, " .") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment