python - Round Sympy Mul with Units -


i'm trying round output of solve evaluation has units attached it.

for example:

solve(eq(x, 22/7 * seconds), x)[0] 

outputs:

3.14285714285714*s 

is there way round 3.14*s while keeping s?

sympy expressions have .evalf() method approximate numbers. accepts optional parameter n, specifies number of digits approximate expression contain.

supposing expression contained in expr variable:

in [5]: expr out[5]: 3.14285714285714⋅s  in [6]: expr.evalf(n=10) out[6]: 3.142857143⋅s  in [7]: expr.evalf(n=2) out[7]: 3.1⋅s  in [8]: expr.evalf(n=3) out[8]: 3.14⋅s 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -