Lesson 5: Star Wars: Building a Galaxy with Code

Grades K-2 | Grades 3-5 | Grades 6-8 | Grades 9-12


In this lesson, learners of all ages get an introductory experience with coding and computer science in a safe, supportive environment. This lesson has two versions.

Option 1: Blocks

The first option uses drag-drop blocks. This version works best for:

  • Students on mobile devices without keyboards
  • Younger students (6+ because the tutorial requires reading)
  • International students

We recommend this for international students because JavaScript syntax is not translated and for the first Hour of Code, the translated blocks provide a better introduction.

Option 2: JavaScript

This option teaches the same basic concepts, but because it uses both drag-drop blocks and JavaScript, the students need to be able to type on a keyboard. For older students on computers, learning JavaScript can be fun and provide an additional challenge. This version of the tutorial is also great if you have some students in your class who have already learned some coding. It is recommended for ages 11+.


This lesson introduces the core CS concepts of coding and programming including sequencing and events. The JavaScript version of the tutorial also lets the students experience typing code.


Getting Started (5 minutes)

Activity (30-45 minutes)

Wrap Up (5 minutes)

Extended Learning

Assessment (2 minutes)


Students will be able to:

  • Define “coding” and “computer science”
  • Identify key computer science vocabulary
  • Make connections between computer science concepts and the real world
  • Identify places to go to continue learning computer science and coding


One Week Before Your Hour of Code

One Day Before Your Hour of Code

  • Write the words “coding”, “programming” and “debugging” on the board or add them to your word wall if you have one.
  • Write the words "Computer Science" in the middle of your board or on piece of paper at the center of a bulletin board. This will serve as your "mind map" for the Getting Ready and Assessment activities.
  • Each student who completes the activity should receive a certificate. Print one for everyone in advance to make this easier at the end of your Hour of Code.


  • code - (v) to write code, or to write instructions for a computer.
  • Debugging - Finding and fixing problems in an algorithm or program.
  • Program - An algorithm that has been coded into something that can be run by a machine.


Report a Bug

Teaching Guide

Getting Started (5 minutes)

Setting the Stage

Welcome students to class and very briefly introduce the day’s activity.

Say: “Today we’re going to spend one hour learning to code. Has anyone here heard the term “code” before? What does it mean?”

Students might mention that a “code” is like a secret message, or that it’s related to computers in some way.

Teaching Tip

One way to introduce the Hour of Code if you are not very familiar with coding yourself is to show one of our inspirational videos. Choose one you think your students will find inspiring, and share it now. For learners in the middle grades, we suggest “Change the World: Hour of Code 2015.”

Explain that in computer science, “code” means a set of instructions that a computer can understand. Let students know that today, they are going to practice “coding,” “programming” and “debugging”.


  • Coding means to write code, or to write instructions for a computer.
  • Programming, similarly, means to write code or instructions. Today, you will program with blocks on the computer (if you’re using an online tutorial) or with pen and paper (if you’re using an unplugged activity).
  • Debugging means to check code for mistakes and try to fix errors.

Ask students to name some jobs they have heard of that are related to coding. Students might mention things such as “programmer”, “computer scientist”, “software developer,” or “engineer”. Capture student responses on your “Computer Science” board, making a mind map of the information your students share.

Say: “You’re right, folks! There are no right or wrong answers here...just about any job these days involves some sort of knowledge of code. While there are many, many careers that require some knowledge of coding, learning to code is something anyone can do. And we’re going to do it today. The things we’re going to do today may not seem immediately like those, but everything you learn today could lead into making the next Angry Birds or Twitter.”

Activity (30-45 minutes)

Challenge your students to complete the Star Wars: Building a Galaxy with Code tutorial.

Depending on the age and ability of your students, you might consider:

  • For younger students, we suggest you break your class into pairs and ask each pair to work together to complete the tutorial using pair programming.
  • For older students, we find that working independently on tutorials works well. Sometimes it helps to allow students to choose their own tutorial. If students aren't interested in Star Wars, they can get a similar experience with the Write Your First Computer Program tutorial.
  • For adult learners, Star Wars: Building a Galaxy with Code works extremely well either as an independent challenge or a pair programming activity.

Teaching Tip

Be sure to play through your chosen tutorials yourself, before asking your students to attempt them. That way you’ll know what to expect and can make decisions about whether to let students choose their own tutorial, or if you want to assign tutorials based on student needs.

At the end of the tutorial, the students have the opportunity to build a Star Wars game. If students finish early, encourage them to try each other's games and then make their own games more interesting or challenging.

You can also let a group or individual attempt another tutorial by visiting code.org/learn.

Wrap Up (5 minutes)


Give each student a few sticky notes or notecards. Facilitate a quick “Whip Around” activity:

  • Pose a prompt that has multiple answers such as “Share back something you really liked about the Hour of Code activity you completed” or “Share some skills you learned today."
  • Have students write down as many responses as possible, one idea per sticky note or note card. “Whip” around the room, calling on one student at a time. Have students share one of their responses. When called on, students should not repeat a response; they must add something new.
  • After completing the whip around, have students discuss which ideas and themes showed up most in their responses.


Explain that you are spending one hour coding today, because this week is CS Education Week, and millions of other students across the globe have also been learning one Hour of Code this week. Congratulate students on being part of this world wide movement.

Give each student a certificate with his or her name on it.

Next Steps

Let students know that if they enjoyed today’s activity, they have many options for continuing to code. Encourage students to visit code.org/learn for a list of options, or, if you’re planning any of the extension activities that follow, tell students what’s coming next in your classroom.

Extended Learning

Beyond an Hour of Code

After your Hour of Code ends, there are many ways to continue teaching computer science in your K-5 classroom. Here are some ideas:

  • Teach the Code Studio Computer Science Fundamentals courses. These four courses are designed for young learners. Students work their way through a series of puzzles that teach them to code, and educators have access to engaging lesson plans that help make the learning coming alive. Code.org offers free professional development for these courses, online or in-person.
  • Research some of the careers in coding you identified today. Find resources on planning career research projects on Sharemylesson.com.
  • Invite a computer science expert to talk to your class about his or her work. Don't know any volunteers, reach out to a few on the volunteer map.

Assessment (2 minutes)

Ask students to add their “Whip Around” sticky notes or note cards to your "Computer Science" mind map on their way out the door. Try to populate the board with lots of great ideas about what CS is and why it matters.