Solve equation of two variable in python by R4R Team

-Here our task to find the value of the equation of two variable.

Example-
Equation is f(x,y)='x+y+3'
then at x=1 and y=2, f(1,2)=6


program-

#take input of equation and variable value
print("Enter equation of two variable in the form of x and y")
equation=input()
print("Enter value of x")
x=int(input())
print("Enter value of y")
y=int(input())

#solve equation by eval
z=eval(equation)
print("Value of equation is",z)


output-

Enter equation of two variable in the form of x and y
2*x+3*y+7
Enter value of x
1
Enter value of y
3
Value of equation is 18


-In this program, we take of equation of two variable and value of the variables then using eval() function we find the value of the equation.




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!