--- title: 18-5:算利息交給電腦 lang: zh-tw tags: DICE Python --- 18-5:算利息交給電腦 === > [name=Chinglin-K] --- 目錄:[Dice 程式教學-Python完整版](https://hackmd.io/@Chinglin-K/Dice-menu) 上一篇:[18-4:一元二次方程式](https://hackmd.io/@Chinglin-K/Dice-18-4) 下一篇:[18-6:算多少利息人都行](https://hackmd.io/@Chinglin-K/Dice-18-6) --- ## 題目 請撰寫一個程式,準備在銀行裡儲存一筆錢,請預估未來10年戶頭的變化。 提示: * 年利率公式: 本利和 = 原存款 * (1+年利率)年數平方。 * math 模組的 pow 可計算平方,如 math.pow(x,y) 會計算出 x 之 y 次方值。 輸入範例: 1000 0.05 輸出範例: year amount on deposit 1 1050.0 2 1102.5 3 1157.6 4 1215.5 5 1276.3 6 1340.1 7 1407.1 8 1477.5 9 1551.3 10 1628.9 --- ## 程式碼 ```Python= n=int(input()) m=float(input()) t=0 print("year amount on deposit") for i in range(1,11): t=n*pow((1+m),i) print(f'{i}',end=" ") print(f'{t:.1f}') ``` --- ## 輸出 ```Python= ``` --- 目錄:[Dice 程式教學-Python完整版](https://hackmd.io/@Chinglin-K/Dice-menu) 上一篇:[18-4:一元二次方程式](https://hackmd.io/@Chinglin-K/Dice-18-4) 下一篇:[18-6:算多少利息人都行](https://hackmd.io/@Chinglin-K/Dice-18-6) --- :::info 「盡多少本分,得多少本事」😊 ::: --- {%hackmd i1nMRrZcTFmTvoF897K9zg %}