Python Level 4: Loops

Chapter 4: The Super Power of Repetition
Name:

Date:
Part 1: The Mining Drill (Tracing)

Be the computer! Look at the loop code and write exactly what it will print in the box.

for i in range(3):
  print("Dig")


energy = 2
while energy > 0:
  print(energy)
  energy = energy - 1

Part 2: How High Does It Go?

If you type range(5), which numbers does the computer count? Circle the correct numbers.

range(5)

0
1
2
3
4
5
6

(Hint: Computers start counting at Zero!)

Part 3: Infinite Danger

One of these loops is broken and will run forever (crash!). Circle the Safe Loop and put an X on the Infinite Loop.

timer = 10
while timer > 0:
  print("Running...")
(Missing math!)
timer = 10
while timer > 0:
  print("Running...")
  timer = timer - 1
(Subtracts timer)
Part 4: The AFK Farmer

Write a Python script that repeats "XP Gained!" exactly 4 times.

# Create a loop for 4 times
for i in range():
(Don't forget to indent!)
    print("")