Lesson Plan - Get It!
I'm sure you have used a microwave oven before. Without thinking, you open its door, put the food in, close it, and press the number. Then, the microwave oven will run the motor, which rotates the glass plate.
As soon as it turns, the microwave energy will cause the water molecules in your food to vibrate. This vibration will increase friction among these molecules, eventually resulting in heat. When the timer is up, the rotating plate stops, and the alarm dings to remind you that its job is complete!
- What if you were asked to tell someone how to use the microwave oven?
- What specific instructions would you give?
Perhaps it would be helpful to keep your instructions very specific in a step-by-step process, as shown below.
- Place the food item in a microwaveable container.
- Open the door of the microwave oven.
- Place the food in the oven's middle of the rotating glass plate.
- Close the door of the microwave oven.
- Press the number of minutes you want the food to be heated; then press START.
- Open the microwave oven and get your food when the alarm dings.
Your interaction with the microwave oven is somewhat similar to the operational characteristics of coding: it involves a series of inputs and outputs.
Opening and closing the door, punching in the number of minutes, and pressing the START button describe the inputs you trigger as a programmer.
By performing these inputs, you expect the microwave oven to perform specific functions such as opening and closing the door, running for the allotted time, rotating the glass plate, ringing the alarm, and heating the food!
In this lesson, you will discover that there is more to coding than a simple set of instructions. Let's get started!
What Is Coding?
The step-by-step instructions on operating a microwave oven may sound simple enough, but we have a problem. Computers are unable to read this type of numbered instruction.
For example, when you open the microwave oven door, the oven's response is not simply allowing you to open it but also to stop emitting microwaves.
In other words, you have one input — opening the door — and the microwave has multiple outputs, allowing you to open the door, turn on the light, and stop microwave emission.
Let's break it apart further!
In the same way as the microwave oven, we ask the computer to do many different things, from sending emails to playing games. In reality, computers do not know what to do by themselves.
They need computer programmers to instruct them in numbers, letters, symbols, or combinations. These instructions are called machine codes.
The number codes in the above photo do not make much sense to humans. A programming language makes understanding the instructions easier for us and the computer.
These are just four out of the 698 programming languages that are currently used. Codes are easier to understand because of these languages.
For instance, you want the computer to say, "Hello, world." Instead of using a set of numbers or symbols, you can use a programming language, as shown below.
- Isn't that easier to understand?
Almost all programming languages work the same way.
- Write the input code and tell the computer what to do: print ("Hello, world")
- The code is compiled to a language that the computer understands.
- The computer executes the code and writes the output "Hello, world" back to you.
In summary, coding uses a programming language to tell the computer what to do.
There is only one instruction line in the above sample code. If you want the computer to do more, multiple lines are written. A document full of lines of code is called a script.
When you see a post on Facebook, you can press a button to like it, love it, or choose an emoji that perfectly describes your reaction.
- Can you imagine what the script would be just for this task?
The programmer had to create multiple lines of code to instruct the computer to respond to your reaction type. Once the script is compiled and executed, the programmer can save the script as part of the entire Facebook program.
Other apps, websites, and even the online games you play are examples of computer programs.
Learning How to Code
Block-based or block-based programming is coding within a programming language where instructions are mainly represented as blocks.
The example above was created using Scratch, which is a block-based visual programming language and an online community. On this website, you can use a block-like interface to create interactive stories, games, and animations.
Code.org is another program that teaches coding. Here, visual blocks can be dragged and dropped to write programs.
These programs deliberately use algorithms. An algorithm is a set of steps that can be followed from start to finish to complete a task.
In block-based coding, you add blocks to direct the sequence of events you want the computer to perform. Here is another more complex example created using Scratch.
You can create free accounts at either (or both!) of these websites to explore and learn more about block-based programming!
Time to head over to the Got It? section to explore different activities that will help you understand the basic computer-coding processes behind every program we enjoy today.