CHECK FOR UNDERSTANDING: Here are a few questions for you to check what you've learned!

  • Click Run and watch the program.
  • Use the code in the editor to answer the questions.
  • Answer the questions by clicking on the correct answer.
  • Click Submit and Next to move on.

penny = codesters.Sprite("penguin") def interval(): rand_color = random.choice(["blue", "yellow", "purple", "green"]) rand_x = random.randint(-240, 240) rand_y = random.randint(-240, 240) color_star = codesters.Star(rand_x, rand_y, 10, 20, rand_color) color_star.set_x_speed(4) color_star.set_y_speed(8) stage.event_interval(interval, 2) def collision(sprite, hit_sprite): color_collided = hit_sprite.get_color() if color_collided == "blue": sprite.say("BLUE!") stage.remove_sprite(hit_sprite) if color_collided == "yellow": sprite.say("YELLOW!") stage.remove_sprite(hit_sprite) if color_collided == "purple": sprite.say("PURPLE!") stage.remove_sprite(hit_sprite) if color_collided == "green": sprite.say("GREEN!") stage.remove_sprite(hit_sprite) penny.event_collision(collision)