alexgonzalez February 2016

how to solve math variable in python? having trouble with =

h = 10 w = 550

I want to solve for x

(8 * x) + (h - 8) * (x * 1.5) = w

# then i want to print answer

print answer

Answers


Joran Beasley February 2016

if you just need to solve you can always use sympy (but i suspect you are looking for something else)

>>> from sympy.solvers import solve
>>> from sympy import Symbol
>>> x=Symbol('x')
>>> h,w=10,550
>>> eqn = 8*x + (h-8)*(x*1.5) - w
>>> solve(eqn,x)

Post Status

Asked in February 2016
Viewed 1,030 times
Voted 11
Answered 1 times

Search




Leave an answer