EMI 計算器:
EMI 計算器可協助您輕鬆估算每月分期付款。一旦您輸入必要的詳細信息,例如貸款金額、貸款期限和利率,銀行的 EMI 計算器將立即顯示您估計的等值每月分期付款 (EMI)。
要計算 EMI,您可以使用以下公式:
EMI = [P x R x ( 1 R )^N] / [( 1 R )^N -1]
地點:
P = 本金
R = 月利率(年利率/12個月)
N = 貸款期限(以月為單位)
範例:
# Input the loan amount loan = int(input("Enter the loan amount: ")) # Input the loan tenure in years and convert to months tenure_year = int(input("Enter the loan tenure in years: ")) tenure_month = tenure_year * 12 # Convert years to months print("Loan tenure in months:", tenure_month) # Input the interest rate per year and convert to monthly interest rate interest_year = float(input("Enter the interest per year: ")) interest_month = interest_year / 12 / 100 # Convert annual interest rate to monthly decimal rate print("Interest per month in percentage:", interest_month) # Calculate EMI using the formula emi = loan * (interest_month * (1 + interest_month) ** tenure_month) / ((1 + interest_month) ** tenure_month - 1) # Display the calculated EMI, rounded to 2 decimal places print("EMI:", round(emi, 2))
輸出:
Enter the loan amount:500000 Enter the loan tenure in years :10 Loan tenure in months: 120 Enter the interest per year:3.5 Interest per month in percentage: 0.002916666666666667 EMI: 4944.29
以上是編寫 EMI 計算器程序的詳細內容。更多資訊請關注PHP中文網其他相關文章!