Teacher's Guide
Chapter 6 / Level 1: Basic if statement
Teaching Objective:
- Learn about conditions and how they can be used
- Learn what an if statement is and it’s syntax
- Learn how to leverage operators with if statements, including:
==,!=
Guide
To complete this exercise walk through the field and collect all the eggs, store them in a list and compare them by setting conditions. This level holds a constant named eggs which represents a general value for eggs in the room.
Collect all eggs, place them inside a list:
basket = ["blue egg", "red egg", "shinny egg", "green egg"]
After placing the eggs in a list, compare them in an if statement, by testing them against each other. Head for the three X marks and compare the items on your list.
if basket[0] == basket[1]:
player.speak("This statement is True!")
else:
player.speak("This statement is False!")
.......
if basket[1] != basket[2]:
player.speak("This statement is True!")
else:
player.speak("This statement is False!")
.......
if basket == eggs:
player.speak("This statement is True!")
else:
player.speak("This statement is False!")
Remember == is an operation to check if two items are the same and != check if two items are not the same.
Map overview and path

Code Solution
import player
player.turn_right()
player.turn_right()
player.move_forward()
player.turn_left()
player.move_forward(10)
basket = ["blue egg", "red egg", "shinny egg", "green egg"]
player.turn_left()
player.move_forward(5)
player.turn_left()
player.move_forward(3)
player.turn_left()
if basket[0] == basket[1]:
player.speak("This statement is True!")
else:
player.speak("This statement is False!")
player.turn_right()
player.move_forward(3)
player.turn_left()
if basket[1] != basket[2]:
player.speak("This statement is True!")
else:
player.speak("This statement is False!")
player.turn_right()
player.move_forward(3)
player.turn_left()
if basket == eggs:
player.speak("This statement is True!")
else:
player.speak("This statement is False!")