案例研究:用 Python 建構軟體
Mark Pedigo, PhD
Principal Data Scientist

新屋房貸評估

+, -, *, /, **
在類別間重複使用程式碼
FinancialCalculator)繼承父類別(BasicCalculator)的所有功能class BasicCalculator:
def multiply(self, x, y):
result = x * y
return result
...
# Child of BasicCalculator
class FinancialCalculator(BasicCalculator):
def months_from_years(self, years):
# Inherits the .multiply() method
return self.multiply(years, 12)
...
doctest 與單元測試

案例研究:用 Python 建構軟體