關於複合利息的 Python 課程


在本文中,我們將瞭解如何解決並解決給定的問題陳述。

問題陳述 - 給定三個輸入值,即本金、利率和時間段,我們需要計算複合利息。

下面給出的程式碼展示了計算複合利息的過程。

這裡使用的公式是

Compound Interest = P(1 + R/100)r

其中,

P 為本金

R 為利率,

T 為時間段

實現如下

示例

 Live Demo

def compound_interest(principle, rate, time):
   CI = principle * (pow((1 + rate / 100), time))
   print("Compound interest : ", CI)
# main
compound_interest(10000, 7.78, 2)

輸出

Compound interest : 11616.528400000001

如下所示,所有變數和函式都在全域性範圍內宣告。

結論

在本文中,我們瞭解了計算複合利息的方法。

Updated on: 25-Sep-2019

467 Views

開拓你的Career

透過完成課程獲得認證

Get Started
廣告
© . All rights reserved.