Guest User

Untitled

a guest
Feb 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. class Fraction:
  4.  
  5.  
  6. @staticmethod
  7. def __from_decimal(n):
  8. digits = len(str(n))
  9. denom = 10**digits
  10. nom = n * denom
  11. return nom, denom
  12.  
  13.  
  14. def __init__(self, num_or_dec, denominator=1):
  15.  
  16. if denomintator == 1 and type(num_or_dec) != int:
  17. self.numerator, self.denominator = self.__from_decimal(num_or_dec)
  18. else:
  19. self.numerator = num_or_dec
  20. self.denominator = denominator
  21.  
  22.  
  23. def simplify(self):
  24. # 3/6 -> 1/2
  25. pass
  26.  
  27.  
  28. def __repr__(self):
  29. return "Fraction(%s, %s)" %(self.numerator, self.denominator)
  30.  
  31.  
  32. def __str__(self):
  33. return "%s/%s" %(self.numerator, self.denominator)
  34.  
  35.  
  36. def __neg__(self):
  37. pass
  38.  
  39.  
  40. def __pos__(self):
  41. pass
  42.  
  43.  
  44. def __abs__(self):
  45. pass
  46.  
  47.  
  48. def __invert__(self):
  49. pass
  50.  
  51.  
  52. def __iadd__(self, other):
  53. pass
  54.  
  55.  
  56. def __isub__(self, other):
  57. pass
  58.  
  59.  
  60. def __imul__(self, other):
  61. pass
  62.  
  63.  
  64. def __itruediv__(self, other):
  65. pass
  66.  
  67.  
  68. def __ifloordiv__(self, other):
  69. pass
  70.  
  71.  
  72. def __imod__(self, other):
  73. pass
  74.  
  75.  
  76. def __ipow__(self, other):
  77. pass
  78.  
  79.  
  80. def __add__(self, other):
  81. pass
  82.  
  83.  
  84. def __sub__(self, other):
  85. pass
  86.  
  87.  
  88. def __mul__(self, other):
  89. pass
  90.  
  91.  
  92. def __truediv__(self, other):
  93. pass
  94.  
  95.  
  96. def __floordiv__(self, other):
  97. pass
  98.  
  99.  
  100. def __mod__(self, other):
  101. pass
  102.  
  103.  
  104. def __pow__(self, other):
  105. pass
  106.  
  107.  
  108. def __bool__(self):
  109. pass
  110.  
  111.  
  112. def __hash__(self):
  113. return hash( (self.numerator, self.denominator) )
  114.  
  115.  
  116. def __lt__(self, other):
  117. pass
  118.  
  119.  
  120. def __le__(self, other):
  121. pass
  122.  
  123.  
  124. def __eq__(self, other):
  125. pass
  126.  
  127.  
  128. def __ne__(self, other):
  129. pass
  130.  
  131.  
  132. def __gt__(self, other):
  133. pass
  134.  
  135.  
  136. def __ge__(self, other):
  137. pass
Add Comment
Please, Sign In to add comment