习题8.9
1.代码实现
点击查看代码
def calculate_monthly_payment(P, r, n):#p:贷款总额,r:月利率,n:还款期数
monthly_payment = P * (r * (1 + r) ** n) / ((1 + r) ** n - 1)
return monthly_payment
total_price = 600000
down_payment = 200000
loan_amount = total_price - down_payment
annual_interest_rate = 0.0036
loan_term = 30 * 12
# 计算每月还款额
monthly_payment = calculate_monthly_payment(loan_amount, annual_interest_rate / 12, loan_term)
print(f"每月还款额为:{monthly_payment:.2f}元")
print("学号:3014")
2.运行结果