In this program, we will find the power of a number.
Steps to solve the program
- Take a number and power as input through the user.
- Create a variable and assign its value equal to 1.
- Multiply the created variable by the number.
- Repeat the above step to find out the power of the number using for loop with the range function.
- Print the output.
num = int(input("Enter the number of which you have to find power: "))
pw = int(input("Enter the power: "))
result = 1
for n in range(pw):
result = result * num
print(result)
Output :
Enter the number of which you have to find power: 5
Enter the power: 4
625