周偉玲Python執行IRR

嵌入周偉玲解說影片

嵌入WIKIPEDIA二分法

pmt = [0,0,0,0] #劉任昌程式設計586設定串列list
pmt[0]=float(input('躉繳金額: '))
for nper in range(1,4):
    pmt[nper] = float(input('第'+str(nper)+'期回收: '))
def npv(rate):
    y = - pmt[0]
    for j in range(1,4):
        y = y + pmt[j]/(1+rate)**j
    return y
a, b, gap, f = 0.0, 1.0, 9.0, 9.0
maxerror = 0.000001
loopNumber = 1
while (gap > maxerror and abs(f) > maxerror and loopNumber < 100):
    loopNumber+=1
    c = (a+b)/2;
    f = npv(c);
    if ( abs(f) > maxerror and gap > maxerror):
        if ( f>0 ):
            a = c
        else:
           b = c
        gap = b-a;
print('報酬率: ', c)
print('淨現值: ', f)
print('迴圈次數: ', loopNumber)

留言

  1. https://nanaminagano.blogspot.com/2025/06/h1margin-0-padding-20px-0-color-000000.html

    回覆刪除
  2. 作者已經移除這則留言。

    回覆刪除
  3. https://lu-chieh-chi.blogspot.com/2025/06/pmt-0000-586list-pmt0floatinput-for.html

    回覆刪除
  4. https://allyking097.blogspot.com/2025/06/pythonirr.html

    回覆刪除
  5. https://shanny11336108.blogspot.com/2025/06/pythonirr.html

    回覆刪除
  6. https://djhdvdhd.blogspot.com/2025/06/blog-post_24.html

    回覆刪除
  7. https://xiyuying.blogspot.com/2025/06/pythonirr.html

    回覆刪除
  8. https://xin00.blogspot.com/2025/06/pythonirr.html

    回覆刪除
  9. https://yangbokai.blogspot.com/2025/06/pythonjavascriptexcelirr.html

    回覆刪除
  10. https://huangchenyang.blogspot.com/2025/06/pythonjavascriptexcelirr.html

    回覆刪除
  11. https://lupeiying.blogspot.com/2025/06/blog-post_24.html

    回覆刪除
  12. https://linchengxun.blogspot.com/2025/06/html-css-javascript-python-java.html

    回覆刪除
  13. https://yuwun0221.blogspot.com/2025/06/pythonirr.html

    回覆刪除
  14. https://wuzhiyou.blogspot.com/2025/06/pythonirr.html

    回覆刪除
  15. https://htmlcss-hsiao.blogspot.com/2025/06/youtube-video-player.html

    回覆刪除
  16. https://yuanxuzhi.blogspot.com/2025/06/pmt-0000-586list-pmt0floatinput-for.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

柯聞折Javascript物件導向方法是物件的函數

甲劉任昌python串列List(陣列Array),元組Tuple,集合Set,字典Dict