Teacher's Guide

Chapter 6 / Level 2: Complex if statement

Teaching Objective:

  • Student learns how to work with if statements with multiple checks
  • Learns how to apply combine() with statements checks
  • Understands how to structure if statements with variable properties.

Guide

For this level, gather all the items in the field and put them in a list named stash.

stash = ["milk", "grape", "strawberries", "red berries", "empty jar"]

After the list is complete, head over to the X marks and combine the items in the list. Using an if statement single out the items and check them using and and or operators and check if they are inside the list by using the in operator. Inside the statement use the combine() function to mix the items.

if "grape" and "empty jar" in stash:
	player.combine(stash)
	# This creates Grape Juice

.......

if "strawberries" or "red berries"  and "milk" in stash:
	player.combine(stash)
	# This creates Berry Milk

Map overview and path

Map overview and path

Code Solution

import player

player.turn_right()
player.move_forward(3)
player.turn_left()
player.move_forward(3)
player.turn_left()
player.move_forward(10)
player.turn_left()
player.move_forward(3)
player.turn_left()
player.move_forward(5)
stash = ["milk", "grape", "strawberries", "red berries", "empty jar"]
player.turn_left()
if "grape" and "empty jar" in stash:
	player.combine(stash)
player.turn_right()
player.move_forward()
player.turn_left()
player.move_forward(3)
player.turn_left()
player.move_forward()
player.turn_right()	
if "strawberries" or "red berries"  and "milk" in stash:
	player.combine(stash)
Chapter 6 / Level 2: Complex if statement | Teacher's Guide