Python Development Course
Chapter
>
Level
Basic Operators
Counting with Code
Did you know you can add (+), subtract (-), multiply ( * ) and divide ( / ) while coding? Well you can! And in this chapter weâre going to teach you how, along with cool ways you can use this feature and how to apply it to what youâve learned.
Letâs start off by counting all the animals in the stable using the speak() function then adding up all their quantities together.

Objective
Determine how many animals there are in each stable and add them up to complete the level.
In this stable you will find cows, goats and pigs, determine how many of each animal are located in each pen. First create a variable where you can store the number of animals that are in each pen, much like this:
cows = [Number of Cows] goats = [Number of Goats] pigs = [Number of Pigs]
Walk towards the X mark in front of each pen and use the speak() function to call out the variable holding the number value for each pen, for example, in the case of cows, like this: player.speak(cows) .
Once youâve completed this for all three pens, head for the X mark in front of the desk and use the speak() function once again but this time adding all three variables, like this: player.speak(cows + goats + pigs). Now, using basic operators, you can add up the number of animals in the stable.