Python-Programming-Lesson-Notes

5.3 Computing Powers With Loops

Exponentiation is built into Python:

print(5 ** 3)
125

Write a loop that calculates the same result as 5 ** 3 using multiplication (and without exponentiation).

Solution
result = 1
for number in range(0, 3):
  result = result * 5
print(result)

Episode 5 exercise 4