In this lesson, we are going to explore some of the coding concepts used to create the Bee Counter. Take a look at the blocks below, they will be used to code your project in the next section.
Sometimes, you might want something to keep happening again and again. Instead of writing many lines of code, we can use something called a “loop” in our code.
Imagine a “Forever Loop” as a magical tool that makes any block nested inside, repeat over and over and over, just like magic that never ends!
This is called a repeating event. This makes the code more efficient by minimizing the lines of code.
Conditional Statements (If-Then)
There are times when we want our computer to do something only when a specific condition is true. We can use a special block called “conditional statements” or “If-Then” block for that. It’s a bit like this: If it’s library day, then you bring your library book. When you have a block nested in the If-Then block, the computer will know to output that block…but only when your condition is true!
*Troubleshooting tip. If a conditional statement isn’t outputting as desired, make sure it is nested in a Forever Loop. This will evaluate the condition over and over again while the program is running. Otherwise, it will only evaluate the condition one time upon starting the program.
In programs, information is really important for making things work. A variable is data that changes throughout the program. Think of a variable like a special container where the computer stores the variable data. It’s like a memory box that helps the computer remember the things you tell it to remember.
For today’s lesson we will be asking our computer to remember the number of bugs who visit your plant. Each visit will change the variable by one!