find the value of 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+x**1+3
then at x=1, f(1)=5
and f(2)=9


program-

print("Enter Quadratic Equation")
equation=input()

print("Enter value of x")
x=int(input())
z=eval(equation)
print("Value of equation at",x,"is",z)

print("Enter value of x")
x=int(input())
z=eval(equation)
print("Value of equation at",x,"is",z)


output-

Enter Quadratic Equation
x**2+x**3+3
Enter value of x
2
Value of equation at 2 is 15
Enter value of x
3
Value of equation at 3 is 39

Enter Quadratic Equation
x**2+1
Enter value of x
1
Value of equation at 1 is 2
Enter value of x
7
Value of equation at 7 is 50

Enter Quadratic Equation
3
Enter value of x
1
Value of equation at 1 is 3
Enter value of x
4
Value of equation at 4 is 3


-In this program, we take a input of quadratic equation and find the value at different value of x.
-In third output, quadratic equation is '3' which is actually '0**2+0**1+3', so at every value of x it return 3.




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!