Write a function that takes a base and a power and finds the power of the base using recursion.


Topic: Write a function that takes a base and a power and finds the power of the base using recursion.

Solution

def power(base,exp):
    if(exp==1):
        return(base)
    if(exp!=1):
        return(base*power(base,exp-1))
base=int(input("Enter base: "))
exp=int(input("Enter exponential value: "))
print("Result:",power(base,exp))



List all Python Programs