Python Program to Calculate the Power of a Number

    

   Python Program to Calculate the Power of a Number 


Program:

result = 1;
base=int(input("Enter a base number: "))
    
exp=int(input("Enter an exponent: "))

while (exp != 0):
        result *= base;
        exp=exp-1;
print("Answer =", result);



OutPut:
Enter a base number: 3
Enter an exponent: 4
Answer = 81

Enter a base number: 2
Enter an exponent: 3
Answer = 8







No comments:

Post a Comment