Nghiên cứu tình huống: Xây dựng phần mềm bằng Python
Mark Pedigo, PhD
Principal Data Scientist

Xác định khoản vay mua nhà mới

+, -, *, /, **
Tái sử dụng mã giữa các lớp
FinancialCalculator) kế thừa toàn bộ chức năng từ lớp cha (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 và unit test

Nghiên cứu tình huống: Xây dựng phần mềm bằng Python