เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

การใช้ Docstring

สร้างคลาส MortgageCalculator เสร็จแล้ว ต่อไปให้เติม docstring เพื่ออธิบาย attribute ต่าง ๆ ของคลาสให้ครบถ้วน

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

กรณีศึกษา: การสร้างซอฟต์แวร์ด้วย Python

ดูคอร์ส

คำแนะนำการฝึกหัด

  • สำหรับ attribute months ให้เพิ่มข้อความว่า the number of months in the loan
  • สำหรับ attribute monthly_payment ให้เพิ่มข้อความว่า the amount of the payment per month

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

class MortgageCalculator(FinancialCalculator):

  """
  A class used to represent a mortgage calculator.

  Attributes
  -------
  months: ____.
  monthly_payment: ____.
  """
  # Code omitted for space
แก้ไขและรันโค้ด