用例子寫一個計算簡單利息的 Python 程序。在我們進入示例之前,讓我向您展示簡單利息計算背後的公式:
單利=(本金利率年數)/ 100
計算單利的 Python 程序
這個 Python 程序允許用戶輸入本金金額、投資回報率和年數。通過使用這些值,程序使用上述公式計算簡單利息。
princ_amount = float(input(" Please Enter the Principal Amount : "))
rate_of_int = float(input(" Please Enter the Rate Of Interest : "))
time_period = float(input(" Please Enter Time period in Years : "))
simple_interest = (princ_amount * rate_of_int * time_period) / 100
print("\nSimple Interest for Principal Amount {0} = {1}".format(princ_amount, simple_interest))
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/219865.html