Young creators, in the last chapter we got to know the "Magic Workbench", and also learned that there is a "Magic Block Box" full of instructions hidden inside the workbench — that's the Blocks Area! Today, we are going to unlock the most core "mini tools" from this block box — Basic Blocks! Essentially, these blocks are the most core "mini tools" in the Magic Workbench, and they are the core helpers for us to write programs~
Just as we need basic tools like scissors, glue and colored paper for handicrafts, writing a program also requires these fundamental building blocks selected from the "magic block box" as "little helpers". They are the "basic skills" of programming; with them, our programs can become capable of "thinking, repeating tasks, calculating and memorizing", instead of simply "doing things in sequence"!
You might be wondering, "What exactly can these building blocks help us do? " Let me give you a few super simple examples:
- To make the program "judge": "If the temperature exceeds 30 degrees, turn on the red light; otherwise, turn on the green light" — you need a "logic judgment block";
- To make a program "perform tasks repeatedly": instead of writing the sequence "turn on the LED + turn off the LED" 10 times to achieve "make the LED blink 10 times", you can get it done in one go with a "loop block";
- To make the program "do the math": "Compare the temperature of 25 degrees with the set 30 degrees and see what the difference is" — you need "math blocks" for this;
- If you want the program to "remember something", for example, "record the current temperature and use it later", you need a "variable block".
Isn't that amazing? With these basic building blocks under our belt, we can write smarter, more flexible programs to accomplish all sorts of fun yet simple tasks, such as an "automatic temperature-controlled night light", a "button-activated counting toy", and many more~
Next, just like picking new friends from a "magic block box", we will unlock these commonly used basic blocks one by one: logic blocks, loop blocks, math blocks, text blocks, list blocks and variable blocks. Each of them can be found in the block area we mentioned in Chapter 1, and they are all very simple. Follow the teacher to learn step by step, and you will soon learn how to use them!
A Little Encouragement: These basic blocks unlocked from the "Magic Block Box" are the foundation of programming, just like how you need to master addition, subtraction, multiplication and division first when learning math~ Learn each one carefully, and later we can combine them to write super cool programs!
Interactive Quick Quiz
- Think about it: What do you usually do that requires "repeating many times"? (For example: skipping rope 10 times, copying new characters 5 times) If you want to implement this with a program, which basic block do you need to help? (Hint: the loop block!)
- Quick Quiz: What type of blocks does a program need to use when it wants to "decide whether to do something"? (Answer: Logic judgment blocks!)
- 2.1 Logic: The building blocks for making "judgments"
- 2.2 Loops: Enabling Programs to "Repeat" Operations
- 2.3 Math: Adding "Computing Power" to Programs
- 2.4 Text: Enabling Programs to "Speak"
- 2.5 Lists: "Drawer" for bulk data storage
- 2.6 Variables: Assigning "Names" to Data
- 2.7 function (Functions): "Package" the program and reuse it