我希望每次循环时我的代码都会以增量递增,但我不确定该怎么做。如何让它重复自己,同时增加10倍,10倍。
这是我到目前为止所做的:
def money():
amount = float(input("Enter NZ convertion amount:$ "))
AUD = amount*0.96
US = amount*0.75
Euro = amount*0.67
GBP = amount*0.496
print('NZ$', amount,'AUD: {}, US:{}, Euro: {}, GBP: {}'.format(AUD, US, Euro, GBP))
return
money()
任何想法?
答案 0 :(得分:1)
AUD = 0.96
US = 0.75
EUR = 0.67
GBP = 0.496
def money(delta, times):
amount = float(input("Enter NZ convertion amount:$ "))
for dta in range(times):
amt = amount + delta * dta
print('NZ$ {} AUD: {}, US:{}, Euro: {}, GBP: {}'.format(amt,
amt * AUD,
amt * US,
amt * EUR,
amt * GBP)
money(10.0, 10)
答案 1 :(得分:0)
为什么不简单地将计算和打印部分包装成10次for循环?
tag_str += ' '
tag_str += tag