python编写程序计算复利-使用Python函数计算复利

写一个函数,在给定的年数后,用给定的初始余额和利率计算银行帐户的余额。假设利息每年复利。在

出现错误“ValueError:索引28处不支持格式字符"I"(0x49)”

这是我目前为止的代码。在def BankBalance():

InputB = 1000

return InputB

print("Your initial balance is $1000")

def Interest():

InputI = 0.05

return InputI

print("The rate of interest is 5%")

def CountNumber():

InputN = float(input("Please enter the number of times per year you would like your interest to be compounded: "))

return InputN

def Time():

InputT = float(input("Please enter the number of years you need to compund interest for:"))

return InputT

def Compount_Interest(InputB, InputI, InputT, InputN):

Cinterest = (InputB*(1+(InputI % InputN))**(InputN * InputT))

print("The compound interest for %.InputT years is %.Cinterest" %Cinterest)

B = BankBalance()

I = Interest()

N = CountNumber()

T = Time()

Compount_Interest(B, I, N, T)

你可能感兴趣的:(python编写程序计算复利-使用Python函数计算复利)