add float method in fraction
This commit is contained in:
parent
1abd903c9b
commit
8e86220b50
@ -56,6 +56,9 @@ class Fraction(object):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "< Fraction " + self.__str__() + ">"
|
return "< Fraction " + self.__str__() + ">"
|
||||||
|
|
||||||
|
def __float__(self):
|
||||||
|
return self._num / self._denom
|
||||||
|
|
||||||
def __add__(self, other):
|
def __add__(self, other):
|
||||||
if type(other) == Fraction:
|
if type(other) == Fraction:
|
||||||
#cool
|
#cool
|
||||||
|
Loading…
Reference in New Issue
Block a user