Python Development Course
Chapter 3
>
Level 2
Objective
Collect eggs and balance the books by adding and subtracting their quantities.
It’s time to collect some eggs in the nesting grounds, walk over and grab the various eggs in the field so we can document how many eggs were lain. Red eggs are different from the white and dark eggs as they are not chicken eggs.
First walk over all the eggs to collect them, then make two (2) variables: total and red_eggs. In the total variable add the amount of all the eggs you’ve gathered of each type, in the red_eggs variable, store how many red eggs you’ve collected.
Once you’ve collected everything, walk to the dark X marks, face the desk and check what the nutritional value is of each egg is. Use the speak() function to multiply (*) the total variable by 90, which is the nutritional value in calories of each egg. Like this: player.speak(total * 90).
After you’re done documenting the nutrition this batch has, head for the light X mark and check the amount of chicken eggs you have. To do this you must subtract (-) the red_eggs variable to the total variable and display the result using the speak function. Like this: player.speak(total - red_eggs), in order to complete the level.