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中文网其他相关文章!