Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- class Fraction:
- @staticmethod
- def __from_decimal(n):
- digits = len(str(n))
- denom = 10**digits
- nom = n * denom
- return nom, denom
- def __init__(self, num_or_dec, denominator=1):
- if denomintator == 1 and type(num_or_dec) != int:
- self.numerator, self.denominator = self.__from_decimal(num_or_dec)
- else:
- self.numerator = num_or_dec
- self.denominator = denominator
- def simplify(self):
- # 3/6 -> 1/2
- pass
- def __repr__(self):
- return "Fraction(%s, %s)" %(self.numerator, self.denominator)
- def __str__(self):
- return "%s/%s" %(self.numerator, self.denominator)
- def __neg__(self):
- pass
- def __pos__(self):
- pass
- def __abs__(self):
- pass
- def __invert__(self):
- pass
- def __iadd__(self, other):
- pass
- def __isub__(self, other):
- pass
- def __imul__(self, other):
- pass
- def __itruediv__(self, other):
- pass
- def __ifloordiv__(self, other):
- pass
- def __imod__(self, other):
- pass
- def __ipow__(self, other):
- pass
- def __add__(self, other):
- pass
- def __sub__(self, other):
- pass
- def __mul__(self, other):
- pass
- def __truediv__(self, other):
- pass
- def __floordiv__(self, other):
- pass
- def __mod__(self, other):
- pass
- def __pow__(self, other):
- pass
- def __bool__(self):
- pass
- def __hash__(self):
- return hash( (self.numerator, self.denominator) )
- def __lt__(self, other):
- pass
- def __le__(self, other):
- pass
- def __eq__(self, other):
- pass
- def __ne__(self, other):
- pass
- def __gt__(self, other):
- pass
- def __ge__(self, other):
- pass
Add Comment
Please, Sign In to add comment