算年化利率的公式

def ap(p,n,r):
    i = 0
    l = 0
    s = 0
    while i <= n:
        l = (s+p-i*p/n)*(r/12)
        i += 1
        s += l
    return s
    
#ap(3999,24,0.04)


import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0.00,0.20,201)
y = ap(3999,24,x)

plt.plot(x,y)
plt.show()

你可能感兴趣的:(python基础)