193k views
1 vote
Write a function integerPower(base, exponent) that returns the value of Baseexponent. For example, integerPower( 3, 4 ) = 3 * 3 * 3 * 3. Assume that exponent is a positive, nonzero integer, and base is an integer. Function integerPower should use for to control the calculation. Do not use any math library functions.

User Tiffannie
by
8.1k points

1 Answer

4 votes

Answer:

def integerPower(base, exponent):

result = 1

for i in range(exponent):

result *= base

return result

Step-by-step explanation:

print(integerPower(3, 4)) would return 81

User Cam Jackson
by
7.4k points