Open this example in the interactive library
Source code
from fractions import Fraction
print(Fraction(1, 3) + Fraction(1, 6))Sample output
1/2

Add rational fractions. A self-contained example using the Python standard library.
Open this example in the interactive library
from fractions import Fraction
print(Fraction(1, 3) + Fraction(1, 6))1/2