Sometimes, you might prefer to get the results in fractions instead of decimals. If so, use a Python built-in function called fractions. The code above shows how it works.
Link to the source code.