- 1
Please i need answer to this question
Write a Python program that allows the user to enter any integer base and integer exponent, and displays the value of the base raised to that exponent. Your program should function as shown below. What base? 10 What power of 10 ? 4 10 to the power of 4 is 10000
2 Réponses
+ 1
base = int(input('What base? '))
pwr = int(input('What power of', base, '? '))
print(base, 'to the power of', pwr, 'is', base**pwr)
0
The answer is pretty simple if you think about it?.
10**0 = 1
10**1 = 10
10**2 = 100 (or 10*10)
You have several solutions for this problem, in Python, you can to exponentiation with ** or if you want to do it "your way" you can try to multiply it in a loop. (there is also a recursive solution for this simple problem)