If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Trace while loops

Problem

Quinn is animating an undersea scene using the ocean module, which can draw sea creatures on the screen at given x and y coordinates.
import ocean

y = 65

# Jellyfish moves left until a shark appears!
ocean.draw_jellyfish(80, y)
ocean.draw_jellyfish(70, y)
ocean.draw_jellyfish(60, y)
ocean.draw_jellyfish(50, y)
ocean.draw_jellyfish(40, y)
ocean.draw_shark(40, y)
Chloe notices a lot of repeated code, so she suggests they refactor the code below the comment to use a loop.
Which code block creates the same animation?
Choose 1 answer: