要求是Input:
n = 6
pmt = 400
discount_rate = 0.12
Expected output:
Call pv_ordinary_annuity8(pmt,n,discount_rate) function
=>> Output: 1644.56
我写的是
n = 6
pmt = 400
discount_rate = 0.12
pv = lambda pmt , discount_rate, n:{pmt*((1-(1/(1+discount_rate)**n))/discount_rate)}
print(pv)
但是输出的是<function at 0x000001BB43783430>
并没有输出结果
请问哪里错了
pv是函数,试试
print(pv(pmt, discount_rate, n))
另外lambda函数中不需要加大括号的,这样导致返回的是一个集合,可改成:
pv = lambda pmt , discount_rate, n: round(pmt*((1-(1/(1+discount_rate)**n))/discount_rate), 2)
这是定义函数,你这输出的肯定是函数地址