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

Method __init__

Day01-15/Day09/rational.py:16–21  ·  view source on GitHub ↗
(self, num, den=1)

Source from the content-addressed store, hash-verified

14class Rational(object):
15
16 def __init__(self, num, den=1):
17 if den == 0:
18 raise ValueError('分母不能为0')
19 self._num = num
20 self._den = den
21 self.normalize()
22
23 def simplify(self):
24 x = abs(self._num)

Callers

nothing calls this directly

Calls 1

normalizeMethod · 0.95

Tested by

no test coverage detected