Using the below compound_by_period function, compute exactly how much money you would have if you started with a penny ($0.01) and doubled it every day for 30 days.
def compound_by_period(balance, rate, num_periods)
balances = [balance]
for n in range(1,num_periods+1):
balance = round( balance * (1 + rate), 2)
balances.append(balance)
return balances
wheat = compound_by_period(1,1,63)
total_wheat = sum(wheat)
/********************main.py*********************/
def compound_by_period(balance, rate, num_periods):
balances = [balance]
for n in range(1,num_periods+1):
balance = round( balance * (1 + rate), 2)
balances.append(balance)
return balances
penny = compound_by_period(0.01,2,30)
totalPenny = sum(penny)
print("\nTotal wheat: ",totalPenny)
Please let me know if you have any doubt or modify the answer, Thanks :)
Get Answers For Free
Most questions answered within 1 hours.