Add an if branch to complete double_pennies()'s base case. Sample output with inputs: 1 10 Number of pennies after 10 days: 1024 Note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message.

Respuesta :

Explanation:

A recursive function double_pennies is created which takes two inputs, the amount of pennies and the number of days.

The base case is

if days == 0:

       return pennies

otherwise function keeps on calling itself until

total = double_pennies((pennies * 2), (days - 1));

Python Code:

def double_pennies(pennies, days):

   total = 0

   if days == 0:

       return pennies

   else:

       total = double_pennies((pennies * 2), (days - 1));

   return total

Driver Code:

pennies = 1

days = 10

print("no. of pennies after", days, "days: ", end="")

print(double_pennies(pennies, days))

Output:

no. of pennies after 10 days: 1024

no. of pennies after 20 days: 1048576

Ver imagen nafeesahmed
Ver imagen nafeesahmed

In this exercise we have to use the knowledge of computational language in python to write the code.

We have the codes in the attached image.

The code in python can be found as:

def double_pennies(pennies, days):

  total = 0

  if days == 0:

      return pennies

  else:

      total = double_pennies((pennies * 2), (days - 1));

  return total

pennies = 1

days = 10

print("no. of pennies after", days, "days: ", end="")

print(double_pennies(pennies, days))

See more about python at brainly.com/question/26104476

Ver imagen lhmarianateixeira