python script to find
nature of the quadratic equation
Answers
heya!!
a = int(input("enter value : "))
b = int(input("enter value : "))
c = int(input("enter value : "))
d= (b * b) - (4 * a * c)
if(d > 0):
root1 = (-b + math.sqrt(d) / (2 * a))
root2 = (-b - math.sqrt(d) / (2 * a))
print("Two Distinct Real Roots Exists: root1 = %.2f and root2 = %.2f" %(root1, root2))
elif(d == 0):
root1 = root2 = -b / (2 * a)
print("Two Equal and Real Roots Exists: root1 = %.2f and root2 = %.2f" %(root1, root2))
elif(d < 0):
root1 = root2 = -b / (2 * a)
imaginary = math.sqrt(-d) / (2 * a)
print("Two Distinct Complex Roots Exists: root1 = %.2f+%.2f and root2 = %.2f-%.2f" %(root1, imaginary, root2, imaginary))
Hope it help
Answer:
heya!!
a = int(input("enter value : "))
b = int(input("enter value : "))
c = int(input("enter value : "))
d= (b * b) - (4 * a * c)
if(d > 0):
root1 = (-b + math.sqrt(d) / (2 * a))
root2 = (-b - math.sqrt(d) / (2 * a))
print("Two Distinct Real Roots Exists: root1 = %.2f and root2 = %.2f" %(root1, root2))
elif(d == 0):
root1 = root2 = -b / (2 * a)
print("Two Equal and Real Roots Exists: root1 = %.2f and root2 = %.2f" %(root1, root2))
elif(d < 0):
root1 = root2 = -b / (2 * a)
imaginary = math.sqrt(-d) / (2 * a)
print("Two Distinct Complex Roots Exists: root1 = %.2f+%.2f and root2 = %.2f-%.2f" %(root1, imaginary, root2, imaginary))
Hope it help