77.6k views
2 votes
Write code to complete doublePennies()'s base case. Sample output for below program with inputs 1 and 10: Number of pennies after 10 days: 1024

User Clio
by
5.8k points

1 Answer

5 votes

In python:

def doublePenny(starting_penny, days):

i = 0

while i < days:

starting_penny = starting_penny * 2

i += 1

return starting_penny

We can test this function with the following code:

print(doublePenny(1,10)). The output will be 1024

I hope this helps!

User ORRs
by
5.9k points