Solve the quadratic equation in python by R4R Team

Quadratic Equation-
-A equation in which highest power of the variable is 2.

Example-
Quadratic equation is f(x)=x**2-3*x**1+2
Then value of x is 1,2 at which f(x)=0


program-

print("Enter value of a,b and c of the quadratic equation")
a=int(input())
b=int(input())
c=int(input())
D=pow(b**2-4*a*c,1/2)
ans1=(-b+D)/(2*a)
print("x=",ans1)
ans2=(-b-D)/(2*a)
print("x=",ans2)


output-

Enter value of a,b and c of the quadratic equation
1
-3
2
x= 2.0
x= 1.0

Enter value of a,b and c of the quadratic equation
1
5
4
x= -1.0
x= -4.0


-In this program, we take an input of the coefficient of equation, then using quadractic formula we find the value of x.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!