Skip to content
Advertisement

Is there a way to do fraction in sympy

I am trying to do fraction using sympy, I know sympy is supports symbolic but can it be done with old fraction, please know that I want it to be display it as unevaluatedexpr here is my code.

from sympy import *
s = (3)/(2) + (4) / (6)
display(s)
init_printing()

Advertisement

Answer

>>> import sympy
>>> a = sympy.Rational(3, 2)
>>> b = sympy.Rational(4, 6)
>>> a
3/2
>>> b
2/3
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement