 # Fraction module

This module provides processing and operations related to rational numbers. It allows to create a Fraction instance from integers, floats, numbers, decimals and strings.

Importing the module :
import fractions # to import whole module from fractions import ____ # to import particular function

Classes :
This module has only one class, Fraction().

Syntax - fractions.Fraction(numerator=0denominator=1)
fractions.Fraction(float)
fractions.Fraction(string)
Note = num and den should be integers and den not equal to 0.

Example :
>>> from fractions import Fraction >>> Fraction(6, 10) Fraction(3, 5)
>>> print(Fraction(6, 10)) 3/5 >>> Fraction(13) Fraction(13, 1)
>>> print(Fraction(13)) 13 >>> Fraction() Fraction(0, 1)
>>> print(Fraction()) 0 >>> Fraction('4/7') Fraction(4, 7)
>>> print(Fraction('4/7')) 4/7
>>> Fraction('4.31') Fraction(431, 100)
>>> print(Fraction('4.31')) 431/100

Attributes and Methods :
1. numerator - Returns numerator of the Fraction
2. denominator- Returns denominatorof the Fraction
3. as_integer_ratio() - Return a tuple of two integers, whose ratio is equal to the Fraction and with a positive denominator.
4. limit_denominator() - This module finds and returns the closest Fraction to self that has denominator at most max_denominator.
Example :
one_fourth = Fraction(1, 4)
one_fourth.numerator -> 1
one_fourth.denominator -> 4
one_fourth.as_integer_ratio() -> (1, 4)

`pi = Fraction(``'3.14159265358979323846'``)`
`pi.``limit_denominator(``1000``) -> 355/113`
`pi.``limit_denominator(``100``) -> 311/99`
`pi.``limit_denominator(``10``) -> 22/7`

`Arithmetic Operations :`
`>>> a, b = Fraction(1, 3), Fraction(1, 4) >>> a + b Fraction(7, 12) >>> a - b Fraction(1, 12) >>> a * b Fraction(1, 12) >>> a / b Fraction(4, 3) ` 