Main content
Course: Intro to computer science - Python?>?Unit 3
Lesson 2: While loopsTrace 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?