MCPcopy
hub / github.com/ZiniuLu/Python-100-Days / normalize

Method normalize

Day01-15/Day09/rational.py:32–36  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

30 return self
31
32 def normalize(self):
33 if self._den < 0:
34 self._den = -self._den
35 self._num = -self._num
36 return self
37
38 def __add__(self, other):
39 new_num = self._num * other._den + other._num * self._den

Callers 5

__init__Method · 0.95
__add__Method · 0.80
__sub__Method · 0.80
__mul__Method · 0.80
__truediv__Method · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected