Is there a way to do fraction in sympy

Tags: , ,



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()

Answer

>>> import sympy
>>> a = sympy.Rational(3, 2)
>>> b = sympy.Rational(4, 6)
>>> a
3/2
>>> b
2/3


Source: stackoverflow