Beginner Coding with Blocks
Chapter
>
Level
Math and Text Operations
Constants and Practice
Objective
Take basket of eggs and store the eggs in containers before addressing how many eggs you stored.
In this level, you'll use a constant named egg_basket which represents the number of eggs in the basket. Constants are like variables that are already set for you - you can use them but not change them. You'll find egg_basket in the Variables category, just like other variables.
Create two variables named bag1 and bag2 to store half of the eggs in each bag.
To set bag1 to half of egg_basket, use the set block with a math block from the Math category. The math block has a dropdown to choose the operator - select divide (÷). Connect egg_basket to the first input and 2 to the second input.
Do the same for bag2 - set it to egg_basket ÷ 2.
Head for the dark X marks in front of containers and use the place block to put the bags in each container. Connect the variable blocks (bag1, bag2) to the place block.
Afterwards head for the light X marks in front of the tables and use the speak block to express how many eggs you have.
On the first light X mark, express how many eggs you have total: Use the speak block with a create text with block to combine "there are ", the egg_basket variable, and " eggs". Click the gear icon on the create text with block to add more items if needed.
On the next light X mark, express how many eggs are in each container: Use the speak block with a create text with block to combine "there are ", bag1, " eggs in bag 1 and ", bag2, " in bag 2". You'll need 5 items in the create text with block.