Computer Science, asked by yp1232, 10 months ago

python script to find
nature of the quadratic equation

Answers

Answered by Anonymous
7

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

Answered by Anonymous
2

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

Similar questions