Python program to find the power of a number using recursion
- Home
- Function in Python
- Python program to find the power of a number using recursion
- On
- By
- 0 Comment
- Categories: Function in Python, function/method
Python program to find the power of a number using recursion
Python program to find the power of a number using recursion
In this tutorial, we discuss the concept of Python program to find the power of a number using recursion
In this post, we can calculateĀ power of a number using recursion in Python language
Program
def power(base,exp):#function declaration if(exp==1): return(base) if(exp!=1): return (base*power(base,exp-1)) base=int(input("Enter the base number..")) exp=int(input("Enter the exponential value..")) print("Result:",power(base,exp))#Calling the function
When the above code is executed, it produces the following results
Result: 81
In this program, user must enterĀ two numbers for power and exponential value to calculate power using recursion in Python language.
The numbers are passed as arguments to the recursive function to calculate the power of the number
Suggestion for you
Similar post
C++ program to find the power of a number using recursion
C program to find the power of a number using recursion
Java program to find the power of a number using recursion