- Students will be able to explain what a programmer does.
- Students will be able to define sequence and how it relates to programming.
- Students will be able to define loops and explain why they are necessary in programming.
- Students will be able to use fractions, degrees, and programming language, including loops, to move a “robot” forward, spin and jump.
- Programmer: A person that writes the code (language) that tells the computer what to do.
- Code: The language that programmers use and create to tell computers what to do.
- Sequence: Sequence is one of three basic flow control structures in programming, and is the very first concept a student must understand when learning to code. Also known as the order of events, a computer will execute commands exactly in the order or sequence they are written. As a programmer, it is important to make sure that the commands given to a computer are in the right sequence, otherwise a program might not run as expected.
- Loops: Loops are one of three basic flow control structures in computer programming, and are an essential feature of every programming language because they enable programmers to run dynamic and complex processes using a small amount of code. Loops are commands that are used to repeat a portion of code until a process is complete, and are essential to many repetitive tasks commonly required in programming.
- Bug: An error or mistake in code syntax.
- Debugging: The process of finding and correcting a mistake in the code.
Direct Instruction (I do) 15 minutes
T (ASK): “Who do you think is smarter, you or a computer? Explain your answer giving reasons.”
Give students 1 minute to turn and discuss with their partner. Call on 3 quiet hands to share their answers.
“People are actually much smarter than computers. In fact, computers can’t do anything without the people who are telling them what to do. The people who tell computers what to do are called programmers.”
Record on the board or chart paper: A programmer is a person who uses code, or programming language, to tell a computer what to do.
T: “Can you share an example of something a programmer would make?”
Call on 3 quiet hands to share their answers. Most students will use games as the example, but try to help them make connections to other things programmers write code for (games, other programs you use at school, cars, airplanes, space ships, iPads, phones).
“All of the games, programs, and things you just talked about are programs created by programmers who tell the computer what to do. Programmers use a special language called code, to create these things. Raise your hand if you think it would be fun to create a game or program a space ship someday.”
Record on the board or chart paper:
Programming Language is the language, or code, that programmers use and create to tell computers what to do.
T: “Programmers use the code that they write to tell the computer EXACTLY what to do. They have to tell the computer what to do in the right order, or it won’t work correctly. This is also known as the order of events. A computer executes the commands (directions), exactly in the order or sequence they are written.”
ASK: “Can you think of a task you need to do in order to get the end result you want?”
Call on 2 quiet hands to share examples of ordered events.
“In programming, sequence makes the computer correctly carry out the directions to make the program work.”
Record on the board or chart paper: Sequence- the order that a computer executes the commands written by the programmer. The computer will follow the sequence exactly as it is written.
“The last thing we need to think about before we program a robot together is repetition. Repetition is the process of repeating the same task- sometimes we repeat what we are doing when we want to save time and minimize mistakes. For example, we may copy and paste something on a computer instead of typing it out more than once. Programmers do this when writing their code to make things go faster or to make sure mistakes aren’t made. This is called a loop. In programming, loops are used to save time and make sure mistakes aren’t made in the code.”
Say and record: Loops are commands that are used to repeat a portion of code until a process is complete. Loops are essential to many repetitive tasks often required in programming.
“Today, we are going to use our knowledge of sequence and loops to act like programmers and move a ‘robot’ together.”
Guided Practice Activity: Beginner: Fourth Grade
Students will act as programmers and apply basic knowledge of programming language and sequence to command a robot to move forward and jump.
Time: 20-25 minutes
- Whiteboard, markers, smart board or writing area that everyone can see.
- It is ideal to have another adult be the robot, but a student would be another option if you don’t have a TA, assistant or room parent.
- Floor space for the robot to move and for students to sit.
Have students seated on at their desks or on the rug area. Explain that another teacher, student, or parent is a robot, and that they need instructions from a programmer. Review that computers aren’t as smart as people.
Explain that we want to program the robot to walk forward and jump. Demonstrate this for them.
T: (Ask) “How do we walk?” (Acceptable response: with our feet, with our legs) Explain that we have to walk “right, left, right, left” so that we don’t end up in the splits. “We need commands to tell our robot to move their right foot and left foot, because our robot won’t know what to do without instructions.”
Write the commands on the board, and explain why they look that way (circle to indicate which foot should stay still and arrow to indicate which leg to move).
T: (Ask) “What should we tell our robot to do first?” (Either right foot or left foot forward) Write the program under “our code” with all commands separated by commas. Ask for the second move.
T: (Ask) “Is this enough steps? How can we tell?” (students should want to test the code)
Chose a student to high-five the robot to activate it. The robot will take two steps forward and crash, then you can “rewind” it.
T: (Ask) “Oh no! Our robot crashed! Why did it crash?” (Because it needs more code to complete the program)
Based on how big the steps are, determine how many more steps need to be taken. Ask students how many more steps are needed. “If we’ve taken two steps and we need to take six, how many more do we need?” (4 more)
T: (Ask) “What is something we can use so that we don’t have to re-write these commands over and over again?” (a loop)
Put arrows around the commands you want to repeat indicating that they will be looped.
T: (Ask) How many times do we want these commands to repeat. Use this opportunity to make the connection to multiplication. Write “x3” next to the looped commands to tell the robot how many times they should loop.
T: After the robot is getting to the correct spot, ask “Now what do we want our robot to do?” (Turn around) “How are we going to tell it to turn around? What shape do we make when we spin?” (a circle) “And which directions can we spin? (left or right)
“Let’s use a circle and an arrow pointing right, to tell our robot to turn right, and a circle and an arrow pointing left to tell our robot to turn left. Now which direction do we want our robot to turn?” (either left or right) Write the code, then test it again.
T: Instruct the “robot” ahead of time to do a complete turn instead of half a turn. When the robot does the turn incorrectly, ask, “Uh oh! What happened?” (Our robot turned too much) “Yes, we made a mistake. When you’re programming is it okay to make mistakes?” (Yes!) “That’s right! A mistake in your code is called a bug! And when we fix bugs in our code we are debugging.”
Open up a discussion about doing a ½ turn rather than a whole turn. Use the opportunity to tie in to fractions or degrees of rotation. Be sure to make the change in your code by adding, “1/2 turn” or “180°” next to your spin command. (pictured above) When the code is corrected, continue.
When it is time to jump, ask the students, “How many legs do we use to jump?” (they should say 2) Use 2 arrows pointing up to mean jump. Write the command and then add it to the code.
Complete the program and run it.
Celebrate! YOU’RE ALL PROGRAMMERS!
Optional: If you have time, you can ask for a “replacement robot”, because yours is almost out of batteries. Choose a student to become the robot and run the program.
Check for Understanding / Informal Assessment
Time: 10 minutes
Ask the class each question. Give 30 seconds for students to think and then turn to share with their partner for 1 minute (Think, Pair, Share). Record answers on chart paper to hang for later reference.
Review programmer, programming language, and sequence.
- What is a programmer?
- What is an example of a program?
- How do computers or computer programs work?
- What happens if we give the computer directions in the wrong order?
- What happens if a programmer forgets a step in their directions?
- What is a command?
- What is a sequence? Why is sequence important?
- What do programmers use to repeat portions of the code until a process is complete?
- What is one benefit of using loops?
Smeeborg Sequence Sector, "1,2,3, Roll" (1.1-1.5) and "Buggy Basics" (1.6-1.10)