शुरू करेंमुफ़्त में शुरू करें

बेहतर वैरिएबल नामों का उपयोग

सही वैरिएबल-नेमिंग कन्वेंशन्स से पठनीयता बढ़ती है, मेंटेनबिलिटी सुधरती है, और त्रुटियाँ कम होती हैं. एक क्लास और एक फंक्शन को नाम देने के लिए उचित नेमिंग कन्वेंशन्स का उपयोग कीजिए.

यह अभ्यास पाठ्यक्रम का हिस्सा है

केस स्टडी: Python में सॉफ्टवेयर बनाना

पाठ्यक्रम देखें

अभ्यास निर्देश

  • क्लास के लिए सही वैरिएबल नाम चुनें. mortgage_calculator और MortgageCalculator में से किसे चुनेंगे?
  • फंक्शन के लिए सही वैरिएबल नाम चुनें. calculate_monthly_payment और CalculateMonthlyPayment में से किसे चुनेंगे?

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Use proper naming conventions for a class name
class ____(FinancialCalculator):
  def __init__(self, loan_amount, annual_interest_rate, years):
    super().__init__()
    self.loan_amount = loan_amount
    self.monthly_interest_rate = self.monthly_interest(annual_interest_rate)
    self.months = self.multiply(years, 12)
  
  # Use proper naming conventions for a function name
  def ____(self):
    numerator = self.monthly_interest_rate * (1 + self.monthly_interest_rate) ** self.months
    denominator = (1 + self.monthly_interest_rate) ** self.months - 1
    multiplier = self.divide(numerator, denominator)
    monthly_payment = round(self.multiply(self.loan_amount, multiplier), 2)
    return monthly_payment
कोड संपादित करें और चलाएँ