# Tracing Code > Ninth graders learn to trace code by hand — following it line by line, tracking each variable in a table, and predicting the output before running it… **Computer Science** | **Grade 9** *A free lesson plan from K12 Academics. Source page: https://lessonplans.k12academics.com/k12-lesson-g9-cs-tracing.html* Ninth graders learn to trace code by hand — following it line by line, tracking each variable in a table, and predicting the output before running it. Tracing is how you truly understand what a program does (and find bugs). They order the steps, then trace a program. **Copy link** works with Canvas, Schoology, Moodle and any other LMS — paste it in as a resource or assignment. ## Everything you need before the bell rings ### Learning Objectives Students will be able to… - **Trace** code by hand. - Track **variables**. - Follow **control flow**. - Predict the output. How can you figure out what code does without running it? ## Order the Tracing Steps Project this and have students put the code-tracing steps in order. ## 55 minutes, five moves Tap any phase to open the teacher moves and student actions. ### Hook — In Your Head Can you predict a program’s output before you run it? #### 👩‍🏫 Teacher Moves - Show a short program. - Ask the question. - Set the goal. #### 🎒 Student Actions - Think. - Share. - Get ready. ### Use — Tracing Students learn. #### 👩‍🏫 Teacher Moves - Send students to Order the Tracing Steps. - Order the steps. - Note track variables in a table. #### 🎒 Student Actions - Order. - Say. - Note it. ### Modify — Trace It Students practice. #### 👩‍🏫 Teacher Moves - Trace a short program. - Fill a variable table. - Predict the output. #### 🎒 Student Actions - Trace. - Table. - Predict. ### Create — Create Students apply. #### 👩‍🏫 Teacher Moves - Trace a program with a loop. - Predict its result. - Run it to check. #### 🎒 Student Actions - Trace. - Predict. - Check. ### Reflect — Reflect Students close. #### 👩‍🏫 Teacher Moves - What do you track while tracing? - Why trace before running? - Complete the exit ticket. #### 🎒 Student Actions - Say it. - Say it. - Complete the exit ticket. ## Built to the standards you report on Aligned to the CSTA K-12 Computer Science Standards and the ISTE Standards for Students. Evaluate and trace program execution. Systematically test and debug. Document and reason about code. Reason about program behavior. ## One lesson, every learner ### Multilingual Learners - Tracing-step cards. - Frame: "I track each ___ in a table." - Trace together slowly. ### Support & Access - Use 3 core steps. - Trace a 3-line program. - Use a variable table template. ### Stretch & Extend - Trace nested control flow. - Find a bug by tracing. - Trace recursion simply. ### What to gather - 📽️Screen / board - 🔍Trace-step cards - 💻Order the Tracing Steps - 📋Variable-table worksheet - 📓Notebooks - 🎫Exit-ticket slips ### Key terms - **trace**: follow code by hand - **variable**: a named stored value - **variable table**: a chart of variable values - **control flow**: the order code runs - **output**: what a program displays - **predict**: say what will happen - **step through**: go line by line - **debug**: find and fix errors ## Exit Ticket Preview the three formative checks. Tap “Sample answer” to see what mastery looks like — hide them before you print for students. ### Reflect: tracing code. Have students trace a program and predict its output. A printable variable-table worksheet is in the CS library. ## Check your understanding **1. What does “trace” mean?** - a named stored value - say what will happen - follow code by hand *(correct)* - go line by line “trace” means: follow code by hand **2. Which word means: “a named stored value”?** - variable *(correct)* - debug - trace - variable table “variable” means: a named stored value **3. What does “variable table” mean?** - a chart of variable values *(correct)* - the order code runs - find and fix errors - a named stored value “variable table” means: a chart of variable values **4. Which word means: “the order code runs”?** - control flow *(correct)* - variable - output - debug “control flow” means: the order code runs **5. What does “output” mean?** - go line by line - what a program displays *(correct)* - say what will happen - a chart of variable values “output” means: what a program displays **6. Which word means: “say what will happen”?** - debug - variable - output - predict *(correct)* “predict” means: say what will happen ## Printable worksheet --- Full lesson page: https://lessonplans.k12academics.com/k12-lesson-g9-cs-tracing.html All lessons: https://lessonplans.k12academics.com/