Teacher's Guide

Chapter 3 / Level 1: Counting with Code

Teaching Objective:

  • Learn how to add variables together
  • Use multiple variables in relation to each other
  • Become familiar with correlating objects in the environment with code objectives

Guide

In this exercise the student will be counting all the animals in their respective pens and adding their amounts together. The objective is to walk to each X mark, look at the stables and create a variables named cows , goats and pigs . Player must then count how many animals of each type are in the pens and add those numbers to each variable. Using the speak() function they will announce how many of each animal is in each pen.

cows = 3
player.speak(cows)

...............

goats = 5
player.speak(goats)

...............

pigs = 4
player.speak(pigs)

Once done the player finalizes the level by walking to the final X mark, facing the table and adding all variables together inside a speak() function.

player.speak(cows + goats + pigs)

Map overview and path

Map overview and path

Code Solution

import player

player.turn_left()
player.move_forward(3)
player.turn_left()
cows = 3
player.speak(cows)
player.turn_right()
player.move_forward(4)
player.turn_left()
goats = 5
player.speak(goats)
player.turn_right()
player.move_forward(4)
player.turn_left()
pigs = 4
player.speak(pigs)
player.turn_right()
player.move_forward(2)
player.turn_left()
player.speak(cows+goats+pigs)
Chapter 3 / Level 1: Counting with Code | Teacher's Guide