def computePV(): #python def函數: {}
r = float(input('輸入利率: '))#float轉為實數
n = float(input('輸入期數: '))
m = float(input('輸入每期金額: '))
f = float(input('輸入終值: '))
pvif = 1/(1+r)**n
pv = (1-pvif)*m/r + f * pvif
print('現值等於 ',pv)
#前面我們用Javascript這裡python
#function: def
#{區段} 同一個縮排indent同一個區段
computePV()
| 利率y(rate) | 期數n(nper) | 金流m(pmt) | 終值f(fv) |
參考劉任昌金融市場講義https://drive.google.com/file/d/17z6UZgN5fC2XCO1L8_BQs57dgQXzbwou/view?usp=sharing
準時交但沒有Excel截圖https://huutingyu.blogspot.com/2025/06/h1-margin-0-padding-20px-0-color-000000.html
回覆刪除610python自定函數計算很完美https://huutingyu.blogspot.com/2025/06/pythonexcel-pv.html
603.https://huutingyu.blogspot.com/2025/06/h1border-30px-outset-red-background.html