Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write code to complete double pennies s base case. Sample output for below progr

ID: 3846285 • Letter: W

Question

Write code to complete double pennies s base case. Sample output for below program Number of pennies after 10 days 1024 Note: These activities may test code with different test values. This activity will perform four tests, with starting pennies F 1 and user days 10, then with starting pennies 1 and user days 40, then with starting pennies 1 and user days 1, then with starting pennies 1 and user days 0. See How to Use zyBooks. Also 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. 1 Returns number of pennies if pennies are doubled num days times 2 def double pennies (num pennies, num days): total pennies Your solution goes h ere else: total pennies double pennies ((num pennies 2), (num days 1)); 10 return total pennies 11 12 Program computes pennies if you have 1 penny today, 13 2 pennies after one day, 4 after two days, and so on 14 starting pennies 1 15 user days 10 16 17 print Numbe of pennies after user-days, days end r 18 print (double pennies (starting pennies, user days)) Run View your last submission V Feedback?

Explanation / Answer

def double_pennies(num_pennies, num_days):
   total_pennies = 0;
  
   if num_pennies == 0:
       return 0
   elif num_days == 0:
       return total_pennies + num_pennies
   else:
       total_pennies = double_pennies((num_pennies*2), (num_days-1))
  
   return total_pennies

starting_pennies = 1
user_days = 10
print('Number of pennies after ', user_days, 'days: ', end="")
print(double_pennies(starting_pennies, user_days ))

OUTPUT 1:

PROGRAM CODE 2:

def print_factorial(fact_counter, fact_value):
   output_string = ''
  
   if fact_counter == 0:
       output_string = '1'
   elif fact_counter == 1:
       output_string += str(fact_counter) + ' = ' + str(fact_value)
   else:
       output_string += str(fact_counter) + ' * '
       next_counter = fact_counter-1
       next_value = next_counter * fact_value
       output_string += print_factorial(next_counter, next_value)
   return output_string

user_val = 5
print('%d! = ' % user_val, end="")
print(print_factorial(user_val, user_val ))

OUTPUT 2:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote