新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python程序:計算簡單利息
創(chuàng)新互聯(lián)Python教程:

在這個簡單的 python 程序中,我們需要找到簡單的興趣。這是一個中級 python 程序。
要理解這個例子,您應(yīng)該了解以下 Python 編程主題:
- Python 語法
- Python 安裝和設(shè)置
- Python 運(yùn)算符
什么是單純的興趣?
在這個求解好的 python 程序中,我們需要計算 Simple Interest,可以用公式 SI = pnr / 100 來計算。在哪里
- p 為本金金額。
- n 為年數(shù)。
- r 為利率。
例如,假設(shè)我們以 10%的利率貸款 1000 英鎊,期限為 1 年。然后通過公式 pnr/100 計算單利得出 1000 10 1 / 100 = 100。所以我們要給 100 盧比作為 1 年的利息。
python 中的單利是如何計算的?
現(xiàn)在在 python 編程語言中應(yīng)用這個邏輯。我們使用 python 語言中的input函數(shù)接受本金、利率和時間的值。然后我們用公式 ( p n r ) / 100 計算利息。
算法
STEP 1: 使用 python 語言的輸入函數(shù)接受本金金額、時間和利率的值。使用浮點(diǎn)和 int 數(shù)據(jù)類型將值轉(zhuǎn)換為整數(shù)。
第二步:用公式 (pnr) / 100 計算單利。
STEP 3: 使用 python 編程語言中的 print 語句打印簡單興趣的值。
Python 源代碼
principle=float(input("Enter the amount :"))
time=int(input("Enter the years :"))
rate=float(input("Enter the rate :"))
si=(principle*time*rate)/100
print("The simple interest is:", si)
輸出
Enter the amount : 1000
Enter the year : 1
Enter the rate : 10
The simple interest is : 100 標(biāo)題名稱:Python程序:計算簡單利息
URL網(wǎng)址:http://www.dlmjj.cn/article/dhgphjj.html


咨詢
建站咨詢
