python的题不会,帮助我下,谢谢

来源:百度知道 编辑:UC知道 时间:2024/05/10 18:58:10
我们老师留的assignment,实在不会了,我们本科生和研究生一起上课,实在不会做,题全是英文,谁能帮助我做的,请留下email,我会给您发过去的,
额,意思就是知道贷款和利率,计算出每个月要还贷多少钱
c = (r / (1 − (1 + r) − N))P0
这个是公式,C是你要还贷的钱数,R是利率,N是还贷的次数,PO是你贷款多少?
下面是例子
For example, for a home loan for $200,000 with a fixed yearly nominal interest rate of 6.5% for 30 years, the principal is P0 = 200000, the monthly interest rate is r = 6.5 / 100 / 12, the number of monthly payments is N = 30 * 12 = 360, the fixed monthly payment equals $1264.14. This formula is provided using the financial function PMT in a spreadsheet such as Excel. In the example, the monthly payment is obtained by entering either of the these formulas:

=PMT(6.5/100/12,30*12,200000)
=((6.5/100/12)/(1-(1+6.5/100/12)^(-30*12)))*200000
= 1264.14

题我去的python论坛发帖问了,人家都回答了,谢谢各位的回答,但是抱歉,没人能回答上来

有点不知道你什么意思:

这个用excel就很好算.是指要用python写成函数么?

首先。如果是等额本息的还款方式,你这个公式我不知道是怎么来的:
因为假设月供M,贴现后总贷款额是L=M*A(n,r)=M*((1+R)^n-1)/R/(1+R)^n
移项后: M=L*R*(1+R)^n/((1+R)^n-1)
这个才是正确的公式.
其中,R是月利率,R=6.5%的年利率/12
M是每月还款,L是贷款本金=200000,n是还款期限(月数),n=30年*12=360月
带入公式,结果为1264.13604698592746409166

用python写:

def PMT(L,r,n):
from math import pow #因为要算乘方
R=r/100/12
N=n*12
M=L*R*pow(1+R,N)/(pow(1+R,N)-1)
return M

然后调用
>>>PMT(200000,6.5,30)
1264.1360469859305
>>>

有问题可以给我留言

好难哦

我试试yeertai@hotmail.com

这跟python没什么关系吧?...
我得知道具体问题