initial = int(input ("What is your initial balance?:"))
interest = float(input ("What is the annual percentage for interest as a decimal?:"))
yearsinvested = input ("How many years is the money being invested for?:")
nextyear=initial*(1+interest)
print ("After year 1:",nextyear ,)
我用什么来计算+打印用户输入的年数?
这是一段时间/ for循环吗?如果声明?
我有精神障碍>。<
答案 0 :(得分:0)
这是一段时间/ for循环吗?如果声明?
是的,根据您的个人品味,这是一段时间或循环。就个人而言,我会去寻找一个for循环! ;)
答案 1 :(得分:0)
这是一个for
循环。请注意,yearsinvested
应为int
。你可以填写其他位
yearsinvested = int(input("How many years is the money being invested for?:"))
for y in range(1, yearsinvested + 1):
# do some stuff here
print ("After year {}: {}".format(y, nextyear))