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

Python recursion

Python function

 

Similar post

C++ program to find the power of a number using recursion

C program to find the power of a number using recursion

 

Recursion in Cpp programming language
Program to Electricity bill calculation using OOP in C++
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

PHP Star Triangle pattern program

PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…

6 months ago

PHP Full Pyramid pattern program

PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…

6 months ago

5 methods to add two numbers in Java

5 methods to add two numbers in Java In this tutorial, we will discuss the…

6 months ago

Python Full Pyramid star pattern program

Python full Pyramid star pattern program In this tutorial, we will discuss  the concept of…

9 months ago

Write a function or method to convert C into F -Entered by user

Write a function or method to convert C into F -Entered by the user In…

1 year ago

How to write a function or method to convert Celsius into Fahrenheit

How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…

1 year ago