Aim:

To write a Python program to find the exponentiation of a number.

Algorithm:

1. Define a function named power()

2. Read the values of base and exp

3. Use ‘if’ to check if exp is equal to 1 or not

i. if exp is equal to 1, then return base

ii.if exp is not equal to 1, then return (base*power(base,exp-1))

4. Print the result.

Program:

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))

Sample Output:

Enter base: 7

Enter exponential value: 2

Result:49