Question: IN JUPYTER NOTE Step 4 : Reference 1 in the Wheat and Chessboard Wikipedia page lists an article entitled A Penny Doubled Every Day for

IN JUPYTER NOTE
Step 4: Reference 1 in the Wheat and Chessboard Wikipedia page lists an article entitled "A Penny Doubled Every Day for 30 Days = $10.7M". It turns out that $10.7M is an approximate total. Using your 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. Assign this total after 30 days to a variable named total_after_30.
Note: this is a little bit different than the wheat and chessboard problem, because there the amount of wheat being placed on a square was doubled every day, but the total amount of wheat on the board is the cumulative sum over all squares up to the current one. The penny-doubled-every-day problem is just a more conventional problem in compound interest, where the balance gets rolled over from day-to-day.
And here is my code
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
balances =compound_by_period(0.01,1,30)
total_after_30=sum(balances)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!