Python Program to find Power of a number

Find Power of a Number

In this Python program we will calculate the power of a number. This program will ask two user inputs, one as base and second is power. So, we have to multiply base value itself with particular number of times which is given as power.
For Example:
Base: 5
Expo: 2
Calculation: 5 * 5
Result: 25
Python Program to find Power of a number


Step 1.  Take user input for base number.

Step 2.  Take user input for exponential, the power of the number.

Step 3.  Take temp variable and initialized with 1.

Step 4.  Initialize For loop, starts from 0 to expo value.

Step 5.  Inside for loop, perform arithmetic multiplication operations between temp and base. And store value in temp variable.

Step 6.  Finally, Print temp variable.

Step 7.  Stop

Python Program:

base = int(input("Enter Base number:"))
expo = int(input("Enter Expo Number:"))
temp = 1

for i in range(0, expo):
    temp = temp * base


# This code is contributed by Shubhanshu Arya (Prepinsta Placement Cell Student) 


Enter Base number: 2
Enter Expo Number: 4

One comment on “Python Program to find Power of a number”

  • Tejendra

    base = int(input(“Enter Base number:”))
    expo = int(input(“Enter Expo Number:”))
    base = base ** expo