Overview of Code.org’s Hour of Code activity

Our activity is a set of 20 self-guided puzzles that teach the basics of computer science for users with no prior experience. In each puzzle, students write a program that gets a character through a maze. The activity uses Blockly, a visual programming language that has blocks you drag and drop to write programs. The activity includes instructional videos before puzzles #1, 6, 10, 14, 18, and a wrap-up video after the last puzzle. The characters in our activity are from the popular kids’ games Angry Birds and Plants vs. Zombies.

Even though students will be using blocks to write code, they will be able to see the code they write represented in Javascript, a text-based language.

Check out the educational standards our activity addresses here (Common Core, NGSS and CSTA standards). And as much as we designed this activity to teach basic computer science, we’re aiming for students to walk away thinking that computer science is fun, approachable, and relevant to their lives.

Our activity is one of the lessons from our free K-8 Intro to Computer Science Course. If you and your students enjoy our Hour of Code activity, consider teaching the whole course.

Prep for the Hour of Code

  1. Go through the tutorial yourself so you can help students during class time. Preview the congrats page to see what students will see when they finish.
  2. Test tutorials and videos on student computers or devices. Make sure they work properly.
  1. Having trouble with Hour of Code videos? The Code.org tutorial videos are hosted on YouTubeEducation.com (not YouTube). This works even in schools that block YouTube. If it doesn't work for you, you can use the "Show Notes" tab to read instructions instead of watching the video. (Meanwhile, please ask your IT department to whitelist the domain "youtubeeducation.com") Or download the videos here; the Hour of Code videos are the first 6 videos listed in that link. You can also download each video directly by clicking on the green "download" button in the video pop-up windows at learn.code.org.
  1. Provide headphones for your class, or ask students to bring their own. (Sound isn’t required for the tutorial, but recommended.)
  2. Don't have enough devices? Use pair programming. When students partner up, they help each other and rely less on the teacher. They’ll also see that computer science is social and collaborative. The three rules of pair programming in a school setting:
  1. The driver controls the mouse and keyboard.
  2. The navigator makes suggestions, points out errors, and asks questions.  
  3. Students should switch roles at least two times a session.
  1. Have low bandwidth? Ask students to click the “Show notes” links to watch storyboards instead of the full videos. You can show videos at the front of the class, so each student isn't downloading videos separately.
  2. Optional: print out certificates for your students to take home. Or if students have their own email address, they can request a certificate at the end of the hour of code.

Right before your class period

  1. Write these links on your white board:
  1. Main activity: hourofcode.com/co
  2. For students who finish early: code.org/learn

During the Hour of Code in your classroom

  1. To start off your class period, inspire students about computer science by showing them one of these videos, featuring Bill Gates, Mark Zuckerberg, Black Eyed Peas founder will.i.am and NBA star Chris Bosh talking about the importance of programming. (There are 1 minute, 5 minute, and 9 minute versions) We’ll also have a video specifically about the Hour of Code, to be released in December.
  2. Briefly explain what computer science means. Here’s an example:
  1. “Computer science is the art of blending human ideas and digital tools to increase our power. Computer scientists work in so many different areas: writing apps for phones, curing diseases, creating animated movies, working on social media, building robots that explore other planets and so much more. Think about things in your everyday life that use computer science: a cell phone, a microwave, a computer, a traffic light… all of these things needed a computer scientist to help build them."
  1. Introduce them to a few tips that will help make your first hour of code go smoothly:
  1. “Ask 3 and then me” rule. Students should ask 3 classmates, and if they don’t have the answer, then they should ask the teacher.
  2. Tell students: “Learning to program is like learning a new language; you won’t be fluent right away.”
  3. Persistance is key in computer science, and it’s worth it because of the satisfaction when you achieve something that you’ve worked really hard on.
  4. Encourage students to run their program often to be able to de-bug (fix) their program more easily. Risk-taking is important in computer science.
  1. Tell students to turn on/log-in to their computer and go to hourofcode.com/co to get started. Our activity begins with a video, so you can watch it as a class or students can watch it individually on their computers. If you watch it as a class, tell students to dismiss the first video that pops up in the activity by clicking on the “X” in the upper right hand corner.
  2. While students are doing the activity, walk around the classroom and answer any questions that they might have. Also, be sure to identify students that are far behind their classmates. An easy way to see this is the orange dot indicating puzzle number at the top of their screen.

When your students come across difficulties

What to do if a student finishes early?

Adjustments for K-2 Teachers

But, really, what do I need to know about computer science to teach the Hour of Code?

A program is a set of instructions for your computer to follow. You build a program using commands. Here is a description of what each command in our activity does:

The move forward block advances a character one space on the grid of the maze.

The turn left block makes the character face to the left. It does not advance the character any spaces on the grid

The turn right block makes the character face to the right. It does not advance the character any spaces on the grid.

The repeat times block is called a loop in computer science. Whatever blocks you put inside this block will be repeated however many times you write in the top of the block. For example, if you put a “move forward” block followed by a “turn left” block inside the repeat times block and set it to repeat for 3 times, this is what will run: move forward, turn left, move forward, turn left, move forward, turn left.

The repeat until block is also a loop. It will repeat (or loop) whatever command you put inside of it until it reaches the end goal or runs into a wall in the maze. This block is useful in cases where you don’t know exactly how many times you need something to repeat until a specific end point.

The if block makes a decision for the computer. It checks to see if the statement on the top is true, and if it is true, the character will do whatever commands you put inside the block. If the statement on the top is not true, the character will do nothing. Note: when you click on the words “to the left”, it reveals a drop-down menu where you can choose other statements, the character can check: if there’s a path to the right or if there’s a path ahead.

The if else block is very similar to the if block, but instead of doing nothing if the statement on the top is true, you can have it do an action or set of actions by placing commands in the “else” spot. For example, if you put a “move forward” block in the spot where it says “do” and you put a “turn left” block where it says “else”, the character will check to see if there’s a path ahead, and it there is, it will move forward, and if there’s not a path ahead, it will turn left. Note: there is also a drop-down menu in this block, just like the if block.

Here are the solutions for each puzzle with notes. Some notes include prompting questions for students, so you can walk around the classroom while students complete the activity and help students one on one who are struggling.  

Puzzle #




Some students may have trouble finding the “Run Program” button. It’s the orange button below the maze.


Some students may have trouble connecting the blocks, so this puzzle reinforces that skill without adding new concepts.


This puzzle introduces the turn block. And now students must avoid obstacles, in this case, a crate of TNT.


This puzzle practices using both left and right turns.


This is the most difficult puzzle that practices the basic sequence of commands. If students get stuck, ask them to put themselves in the character position and what would they need to do to get to the pig?


This program repeats the “move forward” block 5 times to reach the pig. Students might be tempted to just use 5 “move forward” blocks but it’s important to know how to be efficient in computer science. Ask them to imagine if you needed to move forward 1,000 spaces.


The bird has to turn right and then perform the repeat block to get to the pig.


This puzzle needs 2 repeat blocks, and you have to change the number value in the first block from “5” to “4”. To do that, click on the number “5” and make sure it’s highlighted. Then hit the “delete” key on your keyboard and then press “enter” on your keyboard or click on the workspace.


Ask students to think about the solution using just “move forward” and “turn” blocks. Then ask them if they see any patterns that could be repeated. The repeat block is already out on the workspace to encourage students to use it.


This repeats the move forward command until the bird reaches the pig.


Once again, students should be encouraged to look for patterns to decide what actions to repeat.


Some students might write very long programs and then be tempted just to keep adding to them to try and fix them. You might tell them to start with a fresh workspace and ask them to think about the individual commands to get to the sunflower. Then identify a pattern and put those commands inside a repeat block.


This puzzle reinforces concepts from the last puzzle.


For this puzzle, students only have to fill in one block: they have to put a “turn left” block inside the “if” block. This program tells the zombie to repeatedly move forward and every step forward, the zombies check if there’s a path to the left. If the zombie finds a path to the left, it will turn left, and then keep moving forward.


Now, students must re-create code similar to the last level, but this time turning to the right. Ask students to think about what turns are necessary for the zombie to reach the sunflower. They’ll answer “all right-hand turns” and you can ask them to write code that makes the zombie move forward and only turn right when there’s a path to the right.


This is the same code from puzzle 14. You can point out to students that by using the “if” and “repeat” blocks, this program can be used to solve multiple different mazes (rather than just a sequence of move and turn blocks that will only solve a specific path.)


This puzzle is for practice and reinforcement with the “if” and “repeat” blocks.


Ask students how the zombie should get to the sunflower with the fewest number of turns. Then ask them are they left or right hand turns? They’ll say all left-hand turns, and you can tell them that the “if else” block can help you make decisions like that. If there’s a path ahead, move forward, and otherwise, turn left.


This is reinforcing to the last puzzle.


Ask students to read the code that is already out on the workspace. “If there’s a path ahead, what action would you want the zombie to do? Then, if there’s a path to the left, what do you want the zombie to do? And if there’s not a path to the left, what should you put in the “else” spot?” The zombie will move forward IF there’s a path ahead, otherwise it will decide IF there’s a path to the left and then do one of two actions (turn right or turn left) based on that decision.