# How Code Runs: Compilers & Interpreters > Eleventh graders learn what happens between writing code and running it: a computer only understands machine code, so source code must be translated — all at… **Computer Science** | **Grade 11** *A free lesson plan from K12 Academics. Source page: https://lessonplans.k12academics.com/k12-lesson-g11-cs-how-code-runs.html* Eleventh graders learn what happens between writing code and running it: a computer only understands machine code, so source code must be translated — all at once by a compiler, or line by line by an interpreter. They check the ideas, then classify real languages. **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… - Explain **source vs machine code**. - Compare **compiler & interpreter**. - See the **tradeoffs**. - Classify real languages. How does the code you type actually get run by a computer? ## How Code Runs Project each item and have students answer about compilers and interpreters. ## 55 minutes, five moves Tap any phase to open the teacher moves and student actions. ### Hook — Lost in Translation Your computer does not speak Python — so how does it run it? #### 👩‍🏫 Teacher Moves - Pose the question. - Share ideas. - Set the goal. #### 🎒 Student Actions - Think. - Share. - Get ready. ### Use — Compilers & Interpreters Students learn. #### 👩‍🏫 Teacher Moves - Send students to How Code Runs. - Note translation to machine code. - Note compiler vs interpreter. #### 🎒 Student Actions - Answer. - Note it. - Note it. ### Modify — Trace It Students practice. #### 👩‍🏫 Teacher Moves - Say what a compiler does. - Say what an interpreter does. - Name a tradeoff. #### 🎒 Student Actions - Say. - Say. - Name. ### Create — Classify It Students apply. #### 👩‍🏫 Teacher Moves - List a few languages. - Mark compiled or interpreted. - Say one effect of each. #### 🎒 Student Actions - List. - Mark. - Say. ### Reflect — Reflect Students close. #### 👩‍🏫 Teacher Moves - Define machine code. - Compiler vs interpreter? - 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. Explain levels of abstraction and translation. Explain how abstractions hide complexity. Evaluate how programs are executed. Understand how systems run code. ## One lesson, every learner ### Multilingual Learners - Translation diagram. - Frame: "code is translated into ___." - Use a simple example. ### Support & Access - Start with "code must be translated." - One difference. - Use a visual. ### Stretch & Extend - Explain bytecode & the JVM. - Compare compile vs run time. - Time a compiled vs interpreted run. ### What to gather - 📽️Screen / board - ⚙️Translation diagram - 💻How Code Runs - 📋Language sort sheet - 📓Notebooks - 🎫Exit-ticket slips ### Key terms - **source code**: the code you write - **machine code**: instructions the CPU runs - **compiler**: translates all code first - **interpreter**: runs code line by line - **translate**: convert to machine code - **execute**: run the program - **runtime**: while the program runs - **abstraction**: hiding lower-level detail ## Exit Ticket Preview the three formative checks. Tap “Sample answer” to see what mastery looks like — hide them before you print for students. ### Reflect: how code runs. Have students classify real languages as compiled or interpreted. A printable sort sheet is in the CS library. ## Check your understanding **1. What does “source code” mean?** - hiding lower-level detail - the code you write *(correct)* - while the program runs - translates all code first “source code” means: the code you write **2. Which word means: “instructions the CPU runs”?** - execute - machine code *(correct)* - interpreter - abstraction “machine code” means: instructions the CPU runs **3. What does “compiler” mean?** - instructions the CPU runs - the code you write - translates all code first *(correct)* - run the program “compiler” means: translates all code first **4. Which word means: “runs code line by line”?** - abstraction - interpreter *(correct)* - translate - machine code “interpreter” means: runs code line by line **5. What does “translate” mean?** - convert to machine code *(correct)* - instructions the CPU runs - hiding lower-level detail - the code you write “translate” means: convert to machine code **6. Which word means: “run the program”?** - execute *(correct)* - machine code - abstraction - translate “execute” means: run the program ## Printable worksheet --- Full lesson page: https://lessonplans.k12academics.com/k12-lesson-g11-cs-how-code-runs.html All lessons: https://lessonplans.k12academics.com/