PROGRAM :-
import math
print("Enter the following data to find")
print("the solution of quadratic equation:")
a = int(input("Enter coeff of x^2 : "))
b = int(input("Enter coeff of x : "))
c = int(input("Enter constant : "))
d = b*b - 4*a*c
print("Discriminant : ",d)
if d == 0:
print("Roots are real and equal")
r1 = r2 = (-b)/2*a
print("First Root : ",round(r1,2))
print("Second Root : ",round(r2,2))
elif d>0:
print("Roots are real and unequal")
r1 = ((-b)+math.sqrt(d))/2*a
r2 = ((-b)-math.sqrt(d))/2*a
print("First Root : ",round(r1,2))
print("Second Root : ",round(r2,2))
else:
print("Roots are imaginary")
import math
print("Enter the following data to find")
print("the solution of quadratic equation:")
a = int(input("Enter coeff of x^2 : "))
b = int(input("Enter coeff of x : "))
c = int(input("Enter constant : "))
d = b*b - 4*a*c
print("Discriminant : ",d)
if d == 0:
print("Roots are real and equal")
r1 = r2 = (-b)/2*a
print("First Root : ",round(r1,2))
print("Second Root : ",round(r2,2))
elif d>0:
print("Roots are real and unequal")
r1 = ((-b)+math.sqrt(d))/2*a
r2 = ((-b)-math.sqrt(d))/2*a
print("First Root : ",round(r1,2))
print("Second Root : ",round(r2,2))
else:
print("Roots are imaginary")
VIDEO LINK : -
No comments:
Post a Comment
Note: only a member of this blog may post a comment.