top of page
Writer's pictureRajesh Singh

Python program to find the power of a number using recursion


Program:

Hello Students this program is very useful for O Level Practical so read it carefully.

def power(x,y):

if y==0:

return 1

else:

return x * power(x, y-1)

x = float(input("Enter a value of base: "))

y = int(input("Enter value of exponent: "))

result = power(x, y)

print(result)

Output:

Enter a value of base: 2

Enter value of exponent: 3

8.0



33 views0 comments

Recent Posts

See All

Comments


bottom of page