DEMO 2: A conditional is a piece of code that tells your program to do a group of commands if something is true.

There are four parts to a conditional.

  • Click Run to see the if statement and learn how it works!
  • Try running the demo more than once to see what changes!
  • When finished, click Submit and Next to move on.

x1 = 0 y1 = -180 sprite = codesters.Sprite("person1", x1, y1) x2 = random.randint(30,240) y2 = random.randint(-180,-60) butterfly = codesters.Sprite("butterfly", x2, y2) butterfly.set_size(.5) delta_x = x2 - x1 delta_y = y2 - y1 distance = math.sqrt((delta_x**2) + (delta_y**2))