Python‎ > ‎

Fraction

http://www.adilwaseem.com/

Definition
The method return with rational numbers.

Syntax
Fraction(x)

Parameters
x=number or string

Examples
The return is equal to:
 >>> Fraction(2.2)
Fraction(2476979795053773, 1125899906842624)
>>> Fraction(-1.1)
Fraction(-2476979795053773, 2251799813685248)
>>> Fraction(2,3)
Fraction(2, 3)
>>> Fraction(.1)
Fraction(3602879701896397, 36028797018963968)
>>>

The return is:
 >>> Fraction(2.1).__eq__(Fraction(2.1).imag)
False