Question: This is for python Part A Write a recursive function that raises a given number to a given exponent. HINT: Recall that you need to
This is for python
Part A Write a recursive function that raises a given number to a given exponent. HINT: Recall that you need to define a base case and a recursive step, where the function calls itself with a smaller number (exponent). The base case can be the smallest exponent possible, in this case assume it is 1. Your function should: be named exponent_recursive take 2 integer arguments, a number for the base and a number for the exponent return a number as the result Make sure you're writing the function recursively, so you should not be using the ** operator. Graded assert exponent_recursive(3, 2) == 9 Read Only import random Read Only x1 = random.randint(3, 9) x2 = random.randint(1, 9) assert exponent_recursive(x1,x2) == x1**x2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
