在這個簡單的 python 程序中,我們需要找到簡單的興趣。這是一個中級 python 程序。
要理解這個例子,您應該了解以下 Python 編程主題:
- Python 語法
- Python 安裝和設置
- Python 運算符
在這個求解好的 python 程序中,我們需要計算 Simple Interest,可以用公式 SI = pnr / 100 來計算。在哪裡
- p 為本金金額。
- n 為年數。
- r 為利率。
例如,假設我們以 10%的利率貸款 1000 英鎊,期限為 1 年。然後通過公式 pnr/100 計算單利得出 1000 10 1 / 100 = 100。所以我們要給 100 盧比作為 1 年的利息。
現在在 python 編程語言中應用這個邏輯。我們使用 python 語言中的input
函數接受本金、利率和時間的值。然後我們用公式 ( p n r ) / 100 計算利息。
STEP 1: 使用 python 語言的輸入函數接受本金金額、時間和利率的值。使用浮點和 int 數據類型將值轉換為整數。
第二步:用公式 (pnr) / 100 計算單利。
STEP 3: 使用 python 編程語言中的 print 語句列印簡單興趣的值。
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
原創文章,作者:簡單一點,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/127217.html