Unit 3 – Teachers Guide
Unit 3 ยท Algorithms, Flowcharts & Sorting
Your day-to-day companion for delivering Unit 3 โ pacing, standards, lesson plans, misconceptions, differentiation, and a Python error appendix. Unit 3 is where students stop staring at blank screens and start planning before coding. Once they internalize "algorithm first, code second," every project that follows runs smoother.
๐ Welcome โ How to Use This Guide
This Teacher's Guide is your day-to-day companion for delivering Unit 3 of the Code Quest curriculum. It picks up after Unit 2 and assumes students are comfortable with everything from Units 1 & 2 โ variables, data types, operators, if/else, for loops, while loops, lists (read-only), and the 3-step debugging mindset. It's designed for new and experienced CS teachers alike โ no programming background required to use it effectively. Every lesson plan stands on its own; if a substitute teacher takes over for a day, they should be able to pick up the next lesson and run it.
What this guide contains
- A pacing guide showing how Unit 3 maps to roughly 6โ8 class periods, with two-day extensions available for the trickier lessons (Bubble Sort and the capstone).
- A standards & exam crosswalk showing exactly which Florida CTE standards and Coding Fundamentals exam objectives each lesson addresses. Unit 3 is the home of standards 07.02 (algorithms) and 07.06 (pseudocode).
- A unit vocabulary glossary with all 14 key terms students will encounter in Unit 3 โ most of them brand new conceptual vocabulary (algorithm, flowchart, decision diamond, factorial, etc.).
- Five detailed lesson plans (one per lesson), each using the same 7-section format you saw in Units 1 & 2.
- An appendix with the most common Python errors students will see in Unit 3, focused on the new tools (
.append()andsorted()) and lingering Unit 1โ2 carryovers.
How each lesson plan is structured
Every lesson plan in this guide uses the same 7-section format so you can find what you need quickly:
- At-a-Glance โ objective, time, materials, vocabulary, and a quick-reference standards box
- Lesson Flow โ a suggested 45-minute breakdown: warm-up, instruction, guided practice, lab, exit ticket
- Watch For โ the 2โ4 most common student misconceptions, with how to address each in real time
- Differentiation โ what to do for early finishers and what to do for struggling students
- Discussion Prompts โ questions to spark whole-class conversation
- Real-World Connections โ how to answer the inevitable "why does this matter?" question
- Lesson-Specific Vocabulary โ terms introduced or reinforced in that lesson
How to read this in conjunction with the student lessons
Each Code Quest lesson is a self-contained HTML page that students work through at their own pace. This guide doesn't replace those lessons โ it equips you to teach alongside them. The expected workflow:
- Before class: read this lesson plan (5โ10 min) and skim the student HTML lesson, paying special attention to interactive widgets (the Algorithm Builder, the Path Tracer, the Bubble Sort Visualizer, the Factorial Calculator)
- During class: follow the lesson flow; the student HTML is the textbook + lab
- After class: grade the Knowledge Checks and labs against this guide's expectations
๐บ๏ธ Unit 3 Overview
The big picture
Unit 3 introduces the most important shift in students' programming maturity โ plan before you code. Students learn what an algorithm is, how to write one in plain English, how to draw one as a flowchart, then trace through Bubble Sort (their first non-trivial algorithm) and explore factorials (their first taste of mathematical algorithm scaling). The capstone upgrades the Mad Libs game with two new Python tools โ .append() for list-building and sorted() for ordering โ applied through the algorithm-first mindset.
What students learn
- Define an algorithm and apply the three rules every algorithm must follow: precise, ordered, finite
- Write algorithms in plain English (informal pseudocode) before translating to Python
- Read and draw flowcharts using the four standard shapes โ oval (terminator), parallelogram (input/output), rectangle (process), diamond (decision)
- Follow flowcharts with loops by tracing the arrow path back to a previous decision
- Trace Bubble Sort step by step โ comparing adjacent pairs and swapping until the largest values "bubble" to the end
- Distinguish between writing a sort algorithm and using Python's built-in
sorted()โ and explain why both matter - Define a factorial (n!), compute small factorials, and connect factorial growth to nested loops
- Recognize that factorials grow surprisingly fast (10! > 3 million; 20! > 2 quintillion) โ the foundation of "Big O" thinking later
- Use Python's
list = [],list.append(item), andsorted(list)to collect and order data across loop iterations - Apply the "plan first, code second" mindset to a complete project (Mad Libs 3.0)
Prerequisites
Units 1 & 2. Students must be comfortable with: variables, data types, operators, if/elif/else, input(), f-strings, for loops with range(), while loops, list iteration (read-only), and the 3-step debugging mindset. Unit 3 doesn't introduce many new Python keywords โ its work is conceptual.
What comes next
Unit 4 introduces functions and a deeper formal SDLC (the same SDLC students glimpsed in Lesson 2.5). Functions let students name the algorithms they wrote in Unit 3 and reuse them. The "plan first" mindset students build here becomes the discipline that makes Unit 4's modular code clean rather than spaghetti.
Materials you'll need
- Computers with web browser access (one per student, or pairs)
- Knowledge Pillars CodeSkills Lab access
- Projector or large screen โ Unit 3's interactive widgets (Algorithm Builder, Path Tracer, Bubble Sort Visualizer, Factorial Calculator) are designed for whole-class projection
- Whiteboard with multiple colors โ used heavily in Lessons 1, 2, and 3 for live algorithm/flowchart drawing and Bubble Sort traces
- Paper and pencils โ Unit 3 is the most paper-heavy unit so far. Students draw flowcharts on paper before drawing them digitally.
- Optional: printed flowchart shape reference cards (one per student) โ tape to desk for Lessons 2 & 5
- Optional: 5-10 sticky notes per student for the kinesthetic Bubble Sort activity in Lesson 3
โฑ๏ธ Pacing Guide
Unit 3 is designed to fit in 6โ8 class periods of approximately 45 minutes each. Lessons are individually shorter than Unit 2's (no 50-min lesson, no 2-day capstone) โ but the conceptual density is higher, especially in Lessons 2 and 3. Adjust based on how comfortably your students handled Unit 2 loops.
Recommended pacing โ 7-day plan
| Day | Lesson | Focus | Homework |
|---|---|---|---|
| Day 1 | L1: Algorithms | What an algorithm is. Three rules. Algorithm Builder. Lab 3.1A in class. | Finish Lab 3.1B (write an everyday algorithm) |
| Day 2 | L2: Flowcharts | Four shapes. Reading flowcharts. Path Tracer. Shape Match. Lab 3.2A. | Finish Lab 3.2B (draw a flowchart on paper) |
| Day 3 | L3: Bubble Sort (pt 1) | The idea. Visualizer. Trace Pass 1 on the whiteboard. | Read Section 4 (Bubble Sort vs sorted()) |
| Day 4 | L3: Bubble Sort (pt 2) | Predict the Result. sorted(). Lab 3.3A. Knowledge check. | Read L4 Sections 1โ2 (factorials) |
| Day 5 | L4: Factorials | Definition. Growth pattern. Loop connection. Factorial Calculator. Lab 3.4A. | Plan Mad Libs 3.0 algorithm on paper |
| Day 6 | L5: Mad Libs 3.0 Capstone | Algorithm review. Live walkthrough of starter. Build with .append() and sorted(). | Continue building at home |
| Day 7 | L5: Mad Libs 3.0 Capstone | Test. Polish. Reflection. Showcase. Submit. | โ |
Compressed 6-day pacing
If you need to compress: combine Day 3 and Day 4 (cover all of Bubble Sort in one class). This works for stronger groups but rushes Bubble Sort tracing โ students who don't trace at least one full pass on paper rarely internalize how the algorithm works. Recommended only if your students breezed through Unit 2 loops + lists.
Extended 8-day pacing
If you have a shorter class period (30 min) or want deeper coverage: split Lesson 2 (flowcharts) across two days. Day 2 covers shapes + reading flowcharts; Day 3 has students draw their own flowcharts on paper for 3โ4 different problems. Drawing is what locks the concept in โ most teachers wish they'd budgeted more time here.
Suggested grading weights for Unit 3
| Component | Weight | Notes |
|---|---|---|
| Lesson Knowledge Checks (ร4) | 20% | 3 questions each, completed in-platform |
| Lab Exercises (ร7) | 30% | Mix of paper-based (algorithm/flowchart drawing) and CodeSkills Lab |
| Mad Libs 3.0 Final Project | 30% | Capstone โ see 100-pt rubric in Lesson 5 plan |
| Class participation | 20% | Whiteboard work, peer flowchart review, kinesthetic Bubble Sort, reflection writing |
Note: Participation is weighted heavier in Unit 3 than other units because so much of the unit is collaborative and on-paper. The Mad Libs 3.0 capstone is weighted slightly less than Unit 2's because it's a smaller code lift โ the heavy work is in the four conceptual lessons.
๐ Standards & Exam Crosswalk
This crosswalk shows exactly which Florida CTE standards and Coding Fundamentals exam objectives each lesson addresses. Use this for admin reviews, IEP documentation, or to prove alignment when adopting the curriculum. Unit 3's primary "new" standards are 07.02 (algorithms) and 07.06 (pseudocode). Every lesson in the unit carries the "๐ฏ Objective 3" tag โ algorithm understanding and design โ which is the central exam objective.
Florida CTE Standards โ Course #9009200
Standards from the Florida Department of Education Coding Fundamentals curriculum framework that Unit 3 addresses:
| Standard | Description | Lessons |
|---|---|---|
| 01.01 | Use specialized computer coding software to solve problems. | L3, L4, L5 (CodeSkills Lab) |
| 01.02 | Demonstrate proficiency using specialized computer software (e.g., Python). | L3, L4, L5 |
| 02.02 | Explain the components of programming languages. | L3, L4, L5 |
| 05.06 | Recognize that more than one algorithm can solve a given problem. | L3 (Bubble Sort vs sorted()), L5 |
| 05.07 | Create a program that implements an algorithm to achieve a given goal. | L5 (Mad Libs 3.0) |
| 07.01 | Describe the structure of a simple program; explain why sequencing is important. | L1, L2, L5 |
| 07.02 | Explain what an algorithm is; identify and describe common algorithms (sorting, searching). | L1, L2, L3, L4, L5 โ primary unit standard |
| 07.03 | Describe iterative programming structures (loops); explain logic of loop conditions. | L4 (loop connection), L5 (loop reuse) |
| 07.06 | Use pseudocode and/or flowcharts to describe a process. | L1 (pseudocode), L2 (flowcharts), L5 โ primary unit standard |
| 07.07 | Troubleshoot and debug errors in code. | L5 (carryover habit) |
Coding Fundamentals Exam Objectives
Exam objectives that Unit 3 prepares students for. Objective 3 โ algorithm understanding โ is the unit's primary objective; every lesson tags it explicitly.
| Obj | Title | Coverage in Unit 3 | Lessons |
|---|---|---|---|
| 1 | Core programming concepts | Reinforced through capstone | L5 |
| 2 | Analyze and predict code behavior | Heavy โ Bubble Sort tracing, factorial growth prediction | L3, L4 |
| 3 | Algorithm understanding & design | Full coverage โ primary objective for the entire unit | L1, L2, L3, L4, L5 |
| 4 | Write and debug simple programs | Reinforced โ capstone applies algorithm-first habit | L5 |
Lesson-by-lesson alignment
| Lesson | Florida Standards | Exam Objectives |
|---|---|---|
| L1: What is an Algorithm? | 07.01, 07.02, 07.06 | 3 (primary) |
| L2: Flowcharts | 07.01, 07.02, 07.06 | 3 (primary) |
| L3: Bubble Sort | 01.01, 01.02, 02.02, 05.06, 07.02 | 2, 3 (primary) |
| L4: Factorials | 01.01, 01.02, 02.02, 07.02, 07.03 | 2, 3 (primary) |
| L5: Mad Libs 3.0 | 01.01, 01.02, 05.06, 05.07, 07.01, 07.02, 07.03, 07.06, 07.07 | 1, 3 (primary), 4 |
๐ Unit 3 Vocabulary Glossary
All key terms students will encounter in Unit 3. Most are conceptual rather than syntactic โ Unit 3 introduces few new Python keywords but many new ideas. The "Intro" column shows the lesson where the term first appears. Each lesson plan also includes its own focused vocabulary list.
| Term | Definition | Example | Intro |
|---|---|---|---|
| Algorithm | A clear, ordered, finite set of steps that solves a problem. Anyone (or any computer) following the steps gets the same result. | "Brush teeth" recipe; making a sandwich | L1 |
| Pseudocode | Plain-English steps that look a little like code. The bridge between an algorithm and real Python. | "FOR each item: IF X > Y, swap" | L1 |
| Plan-First Mindset | The discipline of writing the algorithm BEFORE typing any code. Saves time and catches bugs early. | "Plan it, then code it" | L1 |
| Flowchart | A picture of an algorithm โ boxes connected by arrows showing the path from Start to End. | (Diagram with shapes and arrows) | L2 |
| Terminator (Oval) | The flowchart shape for Start and End points. Always at the very top and very bottom. | "START" oval | L2 |
| Process (Rectangle) | The flowchart shape for an action or step โ anything that DOES something. | "Set count = 0" | L2 |
| Input/Output (Parallelogram) | The flowchart shape for taking input from the user or printing output. The slanted box. | "Read score" / "Print result" | L2 |
| Decision (Diamond) | The flowchart shape for a Yes/No question. Two arrows leave it โ one for True, one for False. | "Score >= 70?" with Yes/No paths | L2 |
| Sorting Algorithm | An algorithm that puts a list in order (numerical, alphabetical, etc.). There are many; Bubble Sort is one. | Bubble Sort, Merge Sort, Quick Sort | L3 |
| Bubble Sort | A sorting algorithm that compares adjacent pairs and swaps them if out of order. Largest values "bubble up" to the end after each pass. | [3,1,2] โ [1,2,3] | L3 |
| Swap | Exchanging the values of two variables. The basic operation inside Bubble Sort. | a, b = b, a | L3 |
| Pass | One full sweep through the list during a sort. Bubble Sort needs Nโ1 passes for a list of N items in the worst case. | Pass 1, Pass 2, ... | L3 |
| Factorial (n!) | The product of all positive integers from 1 to n. Written with an exclamation mark. | 5! = 5ร4ร3ร2ร1 = 120 | L4 |
List [] | An ordered collection that can hold many values. Created with square brackets. Empty list: []. | animals = [] | L5 |
| .append() | List method that adds one item to the end of the list. Modifies the list in place. | animals.append("dog") | L5 |
| sorted() | Built-in Python function that returns a new sorted version of a list. Doesn't change the original. | sorted([3,1,2]) โ [1,2,3] | L5 |
list = [], .append(), sorted()). The other 13 are conceptual โ students should be able to explain them out loud, not just recognize them on a quiz. Use weekly "explain it back" partner exercises: one student picks a term, the other has to explain it without using the term itself. The four flowchart shapes especially benefit from this drill.
๐ Lesson 1 ยท What is an Algorithm?
Lesson 1 ยท What is an Algorithm?
Lesson PlanAt-a-Glance
Lesson Flow (45 minutes)
๐ฅ Warm-Up (5 min)
- Project this: "Write down the steps for making a peanut butter and jelly sandwich. Be SPECIFIC โ pretend the reader has never seen one before."
- Take 2โ3 examples. Pick the most ambiguous one ("put the peanut butter on the bread" โ but how? With what?) and play "robot teacher": follow it literally and miss obvious things. The class laughs. Reveal: that's exactly what computers do โ they follow exactly what you wrote, not what you meant.
๐ค Direct Instruction (12 min)
- Open Lesson 3.1 on the projector. Walk through Section 1 ("Algorithms Are Everywhere"). Note that students follow algorithms daily โ recipes, morning routines, game rules โ they just don't call them that.
- Walk through Section 2 ("The Three Rules"). On the whiteboard write: PRECISE ยท ORDERED ยท FINITE. Explain each: precise = no ambiguity; ordered = step 1 before step 2; finite = eventually stops (no infinite loops here either).
- Walk through Section 3 ("Writing in Plain English"). Project the side-by-side example โ algorithm in plain English on the left, Python translation on the right. Trace the connection: "ASK for number" becomes
input(), "IF" becomesif, etc. - Emphasize: plan first, code second. This is the Unit's defining mindset and the entire reason this lesson comes before the others.
๐ค Guided Practice (10 min)
- Use the Algorithm Rule Checker in Section 4. Project a few examples; for each, take a class vote: which rule does this break? Then reveal.
- On the whiteboard, write a vague algorithm together: "How to find the biggest number in a list." Take suggestions; rewrite each to be more precise. Show the path from "look at all the numbers and pick the biggest" โ "Set largest to first number; for each number: if number > largest, set largest = number; print largest."
๐ป Independent Lab (13 min)
- Lab 3.1A โ "Write the Algorithm": students pick one of three problems (largest of 3 numbers, even or odd, password checker) and write the algorithm on PAPER first. Then translate to Python in CodeSkills Lab.
- Use the Algorithm Builder widget in Section 5 if students need scaffolding.
- Circulate. The most common student move: skip the paper step and dive into Python. Stop them, hand them the paper, make them do it. The discipline is the lesson.
๐ช Exit Ticket (5 min)
- On paper: "Write a 4-step algorithm for setting an alarm on your phone. Make sure it satisfies all three rules โ precise, ordered, finite."
- Look for: clear step numbers, no ambiguity ("press the button" โ which button?), a clear stopping point. If a student writes 1 step, push back. If they write 15, also push back โ they over-described.
โ ๏ธ Watch For โ Common Misconceptions
๐ฏ Differentiation
For early finishers
Challenge them to write the algorithm for a more complex problem: "Find the second-largest number in a list" or "Reverse a list without using.reverse()." Bonus: have them swap with a partner and try to find an edge case that breaks the algorithm โ the start of testing as a habit.
For struggling students
Stay on the everyday-algorithm exercise (PB&J, alarm, walking to school). Skip the Python translation entirely for class time โ that's homework. The win: they wrote a precise, ordered, finite set of steps in plain English. That IS the lesson.๐ฌ Discussion Prompts
- If you wrote the same algorithm in English and your friend wrote the same algorithm in their own English, would they be the same algorithm? (Yes, if the steps describe the same procedure. Algorithms are language-independent. Two recipes for chocolate chip cookies in English and Spanish are the same algorithm.)
- Why is "be precise" so much harder than it sounds? (Humans share a ton of context implicitly โ we assume the reader knows what a "knife" or "bread" is. Computers share NO context. Precision means stripping out that assumption.)
- If we always write the algorithm first in English, why don't we just do all our coding in English? (English is too ambiguous for a computer. Python is unambiguous. The English plan keeps US clear; the Python translation keeps the COMPUTER clear.)
๐ Real-World Connections
- Recipes. The world's oldest written algorithms. A precisely-written recipe = an algorithm a cook can execute.
- Search engines. Google's PageRank algorithm decides which page to show first. Different algorithm = different ranking. Whoever owns the algorithm owns the internet.
- GPS navigation. "Find shortest route" is an algorithm (Dijkstra's). Different algorithms produce different routes โ Waze vs Google Maps don't agree because they use different ones.
- Social media feeds. Why do you see what you see? An algorithm. The plan-first mindset of Unit 3 is what every engineer at TikTok, Instagram, and YouTube uses every day.
๐ Lesson-Specific Vocabulary
๐บ๏ธ Lesson 2 ยท Flowcharts โ Drawing Your Plan
Lesson 2 ยท Flowcharts
Lesson PlanAt-a-Glance
Lesson Flow (45 minutes)
๐ฅ Warm-Up (5 min)
- Project a road map (any city). Ask: "If I'm here and want to get to here, how do I tell you the route?" Take answers โ they'll naturally describe turns and decisions.
- Reveal: a flowchart is a map for an algorithm. Boxes are the locations; arrows are the roads; diamonds are the intersections where you decide left or right.
๐ค Direct Instruction (12 min)
- Open Lesson 3.2 on the projector. Walk through Section 1 ("The Four Flowchart Shapes"). On the whiteboard, draw all four: oval, parallelogram, rectangle, diamond. Color-code each.
- Drill the meanings using a chant: OVAL = Start/End. PARALLELOGRAM = Input/Output. RECTANGLE = Process. DIAMOND = Decision. Repeat as a class twice.
- Walk through Section 2 ("A Complete Flowchart"). Trace the grade-checker flowchart together โ start at the oval, follow each arrow, watch the diamond split into Yes/No paths.
- Walk through Section 3 ("Flowcharts with Loops"). Show how a loop is just an arrow that goes BACK to a previous decision. The "loop" comes from the arrow path, not a special shape.
๐ค Guided Practice (10 min)
- Use the Interactive Path Tracer in Section 4. Pick scenarios; have students predict the path before clicking.
- Use the Shape Match Challenge in Section 5 โ quick-fire identification. Run it as a class round; project results.
- On the whiteboard, draw an empty flowchart skeleton (just shapes, no labels). Have students suggest labels for each shape to make it a "log into a website" flowchart.
๐ป Independent Lab (13 min)
- Lab 3.2A โ "Read the Flowchart": students follow a flowchart and trace which path they take for given inputs. Pure path-following.
- Lab 3.2B โ "Draw the Flowchart": students draw a flowchart for a simple algorithm on PAPER (not in software). Topics: largest of 2 numbers, even/odd, login retry. Pencil + paper, with the four shapes used at least once each.
- Circulate. Most common issue: students draw a rectangle where a diamond belongs (any time the program "decides," it's a diamond). Second most common: forgetting Start and End ovals.
๐ช Exit Ticket (5 min)
- Project a flowchart with the shapes left blank (just outlines and labels). Students label each shape with its name. Five shapes total โ Start, Read input, If/decision, Process, End.
- Look for 100% correct on the diamond โ that's the most-tested shape on the exam. If a student misidentifies a diamond, they need extra practice before Lesson 3.
โ ๏ธ Watch For โ Common Misconceptions
๐ฏ Differentiation
For early finishers
Have them draw a flowchart for the Mad Libs 2.0 game from Unit 2. This is hard โ there's a nested loop (the for inside the while), at least one decision diamond, and several inputs and outputs. It also previews the Mad Libs 3.0 capstone planning.For struggling students
Stay on Lab 3.2A (read-only path tracing). Skip drawing for class time. The win: identify the four shapes and follow arrows correctly. Drawing can be revisited as homework with a printed shape template they trace into.๐ฌ Discussion Prompts
- What's the advantage of a flowchart over plain-English pseudocode? (Visual layout makes branches and loops obvious at a glance. Easier to spot a missing case (the "no" branch from a diamond) when it's a picture.)
- What's the disadvantage? (Slower to draw than to type. Hard to edit. Doesn't scale to large algorithms โ a flowchart for a 1000-line program is unreadable.)
- Where would a professional engineer choose flowchart over pseudocode? (System diagrams, team communication, requirements docs. Mostly NOT for actual code design โ that's pseudocode's territory. Flowcharts shine when communicating to non-coders.)
๐ Real-World Connections
- UX flow diagrams. Designers draw flowcharts to plan how users navigate apps โ every "Sign Up" screen and "Forgot Password" branch is a diamond.
- Manufacturing. Factory assembly lines have process flowcharts on the wall for every workstation. Quality control checkpoints are diamonds.
- Medical decision trees. Doctors and triage nurses follow flowcharts to decide which test to order next. Lives literally depend on the diamonds.
- Customer support scripts. "Have you tried turning it off and on again?" โ diamond โ "Did that fix it?" โ diamond โ ... is a flowchart powering call centers.
๐ Lesson-Specific Vocabulary
๐ซง Lesson 3 ยท Bubble Sort โ How Computers Sort Lists
Lesson 3 ยท Bubble Sort
Lesson PlanAt-a-Glance
sorted() is preferred in production while still understanding what's happening underneath.Lesson Flow (45 minutes)
๐ฅ Warm-Up โ Kinesthetic Sort (8 min)
- Hand out sticky notes (or index cards) with random numbers 1โ9 to 5โ6 student volunteers. Have them stand in a line in the order they got the numbers.
- Tell them: "Compare yourself to your right neighbor. If your number is bigger, swap places. Then everyone do it again. Keep going until no one swaps."
- The class watches the largest number "bubble" to the right end after Pass 1, then the second-largest after Pass 2, etc. Reveal: that's Bubble Sort.
- This kinesthetic intro is the single most powerful teaching move in Unit 3. Don't skip it even if you feel time-pressed.
๐ค Direct Instruction (10 min)
- Open Lesson 3.3 on the projector. Walk through Section 1 ("How Bubble Sort Works"). Connect to the kinesthetic warm-up: each pair-comparison is one step.
- Use the Interactive Bubble Sort Visualizer in Section 2. Click Step slowly, ask the class to predict each swap before clicking.
- Walk through Section 3 ("Tracing Pass 1"). On the whiteboard, draw a 5-element list and trace Pass 1 by hand. Mark every comparison and every swap. Show that the largest element ends up at the end after one pass.
- Define swap precisely: exchanging two values. In Python:
a, b = b, a. Show why a temporary variable is used in many languages but Python doesn't need one.
๐ค Guided Practice (10 min)
- Use the Predict the Result challenges in Section 4 โ give a starting list, predict the state after Pass 1.
- Walk through Section 5 ("Bubble Sort vs Python's sorted()"). Project both side by side. The big point: knowing Bubble Sort teaches you HOW computers sort; using
sorted()is what you ACTUALLY do in real code. Both matter.
๐ป Independent Lab (12 min)
- Lab 3.3A โ "Trace and Predict": students trace 2 full passes of a Bubble Sort on a 6-element list, on paper, with a trace table.
- Lab 3.3B โ "Use sorted()": in CodeSkills Lab, students use
sorted()to sort lists of numbers and strings. They confirm that the original list isn't changed (sorted returns a new list). - Circulate the paper trace closely. The most common error: students swap on every comparison, even when the order is already right. The rule is "swap ONLY if left > right."
๐ช Exit Ticket (5 min)
- On paper: "Show the state of
[4, 1, 3, 2]after one full pass of Bubble Sort." - Answer: [1, 3, 2, 4]. Walk: compare 4&1 โ swap โ [1,4,3,2]. Compare 4&3 โ swap โ [1,3,4,2]. Compare 4&2 โ swap โ [1,3,2,4]. The 4 is now at the end. Note: 3 and 2 are still out of order โ that's Pass 2's job.
โ ๏ธ Watch For โ Common Misconceptions
sorted().sorted() is a professional tool. You need both.๐ฏ Differentiation
For early finishers
Challenge: trace ALL passes of Bubble Sort on a 6-element list โ record the state after each pass. Then explain in 2 sentences why Bubble Sort gets faster as it goes (each pass only needs to scan the unsorted portion). Stretch: research Selection Sort and explain how it differs from Bubble Sort in one paragraph.For struggling students
Stay on Pass 1 only. Use the kinesthetic warm-up as the lesson's anchor โ physically swap sticky notes on the desk. Use Lab 3.3B (justsorted()) instead of Lab 3.3A (the trace). The win: they can use Python's sorting, even if they can't yet trace Bubble Sort by hand.
๐ฌ Discussion Prompts
- How would you sort a deck of cards by hand? Is your method like Bubble Sort, or different? (Most people use Insertion Sort intuitively โ pick a card, insert it where it belongs. This previews Unit 9 algorithms โ students re-encounter sorting choices.)
- If Bubble Sort is slow, why do textbooks teach it first? (It's the simplest sorting algorithm to understand and trace. Pedagogically, it's the perfect first sort.)
- Could a person using Bubble Sort ever beat a person using a different algorithm? (For a list of 3 items, yes โ they're all about the same. For 1,000 items, no โ Bubble Sort scales terribly. The size of the data is what makes the algorithm choice matter.)
๐ Real-World Connections
- Sorting your phone's photos by date. The phone runs a sort algorithm โ almost certainly NOT Bubble Sort (it's too slow), but the same fundamental "compare and arrange" logic.
- Spreadsheets. Click a column header to sort. Excel and Google Sheets use a hybrid sort algorithm called Timsort โ built on the same comparison principles you learned today.
- Search rankings. Google returns results in a sorted order (most relevant first). The "score" of each page is sorted using a fast algorithm โ but the COMPARISON step is the same idea you saw in Bubble Sort.
- Tournament brackets. Single-elimination tournaments are essentially a sorting algorithm โ comparisons (matches) reveal the "largest" (best) team.
๐ Lesson-Specific Vocabulary
a, b = b, a.๐ข Lesson 4 ยท Factorials โ Multiplying All the Way Down
Lesson 4 ยท Factorials
Lesson PlanAt-a-Glance
Lesson Flow (45 minutes)
๐ฅ Warm-Up (5 min)
- Ask: "How many ways can you arrange 3 books on a shelf?" Take guesses. Walk it: 3 choices for first, then 2 for second, then 1 for last โ 3 ร 2 ร 1 = 6.
- Ask: "Now 5 books?" Most will guess too low. The answer is 5 ร 4 ร 3 ร 2 ร 1 = 120. Reveal: "That's a factorial. Today we learn what they are and why they grow so fast."
๐ค Direct Instruction (10 min)
- Open Lesson 3.4 on the projector. Walk through Section 1 ("What is a Factorial?"). Define: n! = n ร (nโ1) ร (nโ2) ร ... ร 2 ร 1.
- Walk through Section 2 ("The Factorial Table"). Project the table โ 1!=1, 2!=2, 3!=6, 4!=24, 5!=120, 10!=3,628,800, 20!>2 quintillion.
- Walk through Section 3 ("How Fast Do Factorials Grow?"). Compare 10! (~3.6 million) to 2ยนโฐ (1024). Factorials grow MUCH faster than exponentials. This is the foundation for "Big O" thinking later in Unit 9.
- Walk through Section 4 ("How Factorials Connect to Loops"). Show the for-loop pattern:
result = 1; for i in range(1, n+1): result *= i. This is a Unit 2 callback โ a counter, but multiplying instead of adding.
๐ค Guided Practice (8 min)
- Use the Factorial Calculator in Section 5. Compute 7!, 8!, 12! together. Confirm by hand on the whiteboard for 7!.
- Use the Factorial Challenges in Section 6 โ students try a few mentally before checking.
- Project Section 7 ("Where Factorials Show Up") โ how many ways to seat 8 people, password permutations, route planning. Factorials are why password cracking is hard and routing is famously slow.
๐ป Independent Lab (15 min)
- Lab 3.4A โ "Build the Factorial Function": in CodeSkills Lab, students write a for-loop that calculates n! for any n the user enters. Validate with input.
- Lab 3.4B โ "Find the Tipping Point": students keep increasing n until the result is "too big to be useful" โ the discovery moment when 20! makes them say "whoa." Pure intuition-building exercise.
- Circulate. The single most common bug: starting
result = 0instead ofresult = 1. Anything times 0 is 0, so the answer is always 0. Direct echo of the counter-pattern lesson from Unit 2.3 โ initialize to the right value.
๐ช Exit Ticket (5 min)
- On paper: "Without a calculator, what is 6! ? Show your work."
- Answer: 6 ร 5 ร 4 ร 3 ร 2 ร 1 = 720. Look for the multiplication chain. If a student writes "720" with no work, push for the chain โ the process IS the lesson.
โ ๏ธ Watch For โ Common Misconceptions
result = 0 at the start; anything ร 0 = 0 forever.๐ฏ Differentiation
For early finishers
Challenge: write a Python program that prints the factorial table from 1! to 15! using a for-loop. Bonus: research and explain the connection between factorials and "permutations" โ why n! tells you how many ways to arrange n things in a row. Stretch: investigate why 70! is too big for a calculator (overflow) but Python handles it fine (arbitrary precision integers).For struggling students
Skip Lab 3.4B. Stay on Lab 3.4A but limit n to โค 6 (so they can verify by hand). The win: understand that n! means "multiply down to 1" and write a working loop. The growth-rate insight is bonus.๐ฌ Discussion Prompts
- If a password is 8 characters and each character has 26 options, how many possible passwords? (26โธ โ 209 billion โ exponential, not factorial. Distinguish the two.)
- If you're scheduling 10 students into 10 different time slots (each gets one slot), how many possible schedules? (10! = 3,628,800 โ that's why scheduling software is hard!)
- Why does it matter for computer science that factorials grow so fast? (Some algorithms run in n! time. They're useless for n > ~12. Knowing factorial growth helps engineers spot doomed algorithms early. This is direct setup for Big O in Unit 9.)
๐ Real-World Connections
- Traveling salesman. Visit 10 cities and return home in the shortest order โ there are 10!/2 possible routes. For 20 cities, 20!/2 โ more atoms than in some galaxies. This is THE classic hard algorithm problem.
- Password cracking. A 5-letter password (any 26 letters) has 26โต โ 12 million possibilities. A 5-letter password where every letter is unique has only 26 ร 25 ร 24 ร 23 ร 22 = 7.9 million. Permutations show up in security math.
- Cryptography. The Enigma machine used in WWII produced ~159 quintillion possible settings โ a factorial-derived number. Cracking it required a different algorithm (and a person named Alan Turing).
- Genetics. A 10-gene sequence can shuffle in 10! = 3.6 million ways. Bioinformatics is built on factorial counting.
๐ Lesson-Specific Vocabulary
๐ฎ Lesson 5 ยท Mad Libs 3.0 โ Sorted Edition Capstone
Lesson 5 ยท Mad Libs 3.0 Capstone
Project PlanAt-a-Glance
.append() to collect entries across rounds and sorted() to display them alphabetically. They will demonstrate the algorithm-first mindset from Lesson 1 in a real project context.[], .append(), sorted(), plus all prior Unit 3 vocabulary.append(), sorted()) are tiny additions. The pedagogical work this capstone does is enforcing the algorithm-first habit โ students MUST write 6 plain-English steps before coding. The discipline is the deliverable, not the code complexity.
Project Flow (45 min single-day version)
๐ฅ Warm-Up (5 min)
- Project Mad Libs 2.0 (the version students built in Unit 2). Ask: "If we wanted to remember every animal players entered across all 3 rounds, how would we do it?" Steer toward "save them in a list."
- Reveal: today we add two tiny tools โ
.append()andsorted()โ that turn a one-shot list into a growing, then sorted, collection.
๐ค Direct Instruction โ Two New Tools (8 min)
- Open Lesson 3.5 on the projector. Walk through "The Two New Tools" section.
- Live-code
.append():animals = []before, thenanimals.append("dog"),animals.append("cat"),print(animals). Output:['dog', 'cat']. Note the empty-list start. - Live-code
sorted():print(sorted(animals)). Output:['cat', 'dog']. Crucial point:sorted()returns a NEW list โ the original is unchanged. - Connect to Unit 2:
animals = []initialized BEFORE the loop,.append()INSIDE the loop,sorted()read AFTER. Same three-place pattern as Unit 2's counter โ but accumulating items instead of counting.
๐ฏ Algorithm First (10 min)
- Distribute paper. Project the empty algorithm template:
- Create empty list before loop
- Loop runs 3 times
- Inside loop: collect inputs from player
- Inside loop:
.append()animal to list - Inside loop: tell the story
- After loop: print sorted list
- Have students write THEIR version of the 6 steps in their own words. Walk around. No one opens CodeSkills Lab until their plan is on paper. This is the lesson.
๐ป Build (17 min)
- Students copy the starter code into CodeSkills Lab. Their algorithm goes at the top as a comment block.
- They fill in the missing pieces. The starter has the structure โ they add the story, the prompts, and the sorted output.
- Circulate. The most common bug:
animals = []placed INSIDE the loop instead of before (resets each round, ends with only 1 animal). Echo of Unit 2.3 counter bug โ same shape, different content.
๐ Showcase & Submit (5 min)
- Pick 2โ3 volunteers to run their Mad Libs 3.0 in front of the class. Class members supply the words.
- The reveal at the end: the sorted list of all the animals players entered. Audible "ohh" when students realize they've built something with memory across rounds.
- Submit via the in-platform checklist + reflection box.
Two-Day Pacing (90 min total)
If you have flexibility โ split as Day 1 (algorithm planning, build with help) and Day 2 (test, polish, showcase, submit). The flowchart bonus challenge from the lesson works well as a Day 1 stretch task. The Day 2 showcase tends to be more polished if students sleep on their work.
โ ๏ธ Watch For โ Common Project Pitfalls
animals = [] is INSIDE the loop, so it resets every round. Move it BEFORE the loop. Direct callback to Unit 2.3 counter-init bug โ students should recognize the pattern.animals = animals.append("dog") โ they expect .append() to return the new list..append() modifies the list in place and returns None. So animals becomes None โ and the next iteration crashes with AttributeError: 'NoneType' object has no attribute 'append'. The fix: just animals.append("dog") on its own line.sorted() changes the original."sorted(animals) as a statement (not assigning the result) and expects animals to now be sorted. It isn't.sorted() returns a NEW sorted list; doesn't modify the original. Either assign the result (sorted_animals = sorted(animals)) or print it directly (print(sorted(animals))). Distinguish from list.sort() which DOES modify in place โ but isn't taught here.๐ฏ Differentiation
For students who finish early
Direct them to the bonus challenges from the lesson: Silver = sort two lists (animals AND adjectives). Gold = draw the complete flowchart for Mad Libs 3.0 on paper, attach as a photo. Platinum = deduplicate usingset() โ research independently, demonstrate. Each adds +5 pts (max +20).
For struggling students
It's OK if their version only has the for loop with.append() and skips sorted(). They demonstrated the list-collection pattern. Add sorted() as a stretch the next class. Even better: have them work in a pair with a stronger student โ the algorithm-first habit transfers between students well during pair work.
๐ฌ Discussion Prompts
- How is
animals.append(x)like the counter pattern from Unit 2 (count += 1)? (Same three-place structure: initialize before the loop, update inside, read after. The difference: counter accumulates a number, list accumulates items.) - Why does
sorted()return a NEW list instead of changing the original? (Functional design โ it's safer not to mutate inputs. Useful when you want both the original order and a sorted view.) - If you finished, would Mad Libs 4.0 (next year) be easier to plan because of what you learned today? (Reflection prompt โ the algorithm-first habit IS the transfer skill. Whatever Mad Libs 4.0 looks like, the plan-then-code approach is the same.)
๐ Real-World Connections
- Online shopping carts. Every "Add to Cart" button is
.append()in disguise. The cart is a list; clicking adds an item; checkout sorts/groups before display. - Music playlists. Adding songs to a playlist is
.append(). "Sort by artist" issorted(). Building a playlist is the same pattern as Mad Libs 3.0. - Photo albums. Phone photos accumulate via
.append(); "Sort by date taken" issorted(). Modern apps run this every time you open the gallery. - Survey responses. Every form submission appends a row; admins view sorted results. The bones of every survey tool.
๐ Mad Libs 3.0 Project Rubric (100 points)
The student lesson uses a 13-item checklist; this guide adapts it into a 100-point rubric for grading consistency with Units 1 & 2. Share this rubric with students at the start of the project.
| Category | What to look for | Pts |
|---|---|---|
| Algorithm Plan (the headline category) | 6+ step plain-English algorithm written as a comment block at the top of the file. Steps are numbered, precise, ordered, and finite. The plan must clearly identify where the list is created, where .append() happens, and where sorted() happens. | 25 |
| List + .append() Pattern | all_animals = [] created BEFORE the loop. .append(animal) called INSIDE the loop on each iteration. | 15 |
| sorted() Output | After the loop, the program prints the list of animals in alphabetical order using sorted(). Output is clearly labeled. | 10 |
| For Loop & Round Structure | Inner for loop runs 3 rounds. Round counter labels the rounds clearly for the player. | 10 |
| If/Else Inside Loop | Conditional inside the for loop creates a different ending message based on a value (e.g., the number entered). | 10 |
| Story Output | Story uses f-strings to plug in player words. Output is readable and fun. | 10 |
| Comments & Style | Header comment, inline comments per step, snake_case variable names, 4-space indentation. At least 5 inline comments. | 10 |
| Works Correctly | Program runs end-to-end without errors. Plays all 3 rounds. Sorted list contains all 3 entered animals. | 10 |
| TOTAL | 100 | |
๐ Stretch Goals (extra credit)
- Silver โ sort TWO lists (animals AND adjectives) collected separately: +5 pts
- Gold โ drawn flowchart of Mad Libs 3.0 on paper, photo attached: +5 pts
- Platinum โ deduplication using
set()or an if-check: +5 pts - 5 rounds instead of 3 (with all messages updated): +5 pts
Maximum stretch credit: +20 points. Document each stretch goal in a comment at the bottom of the file.
๐ Lesson-Specific Vocabulary
[] โ An ordered collection that can hold many values. Created with square brackets. Empty list: [].animals.append("dog").๐ ๏ธ Appendix ยท Common Python Errors in Unit 3
This appendix lists the most common Python error messages students will see in Unit 3, focused on the new tools (.append(), sorted()) and the carryover errors from Units 1โ2 that resurface in the capstone. Unit 3 introduces relatively few new error types โ but the algorithm-first mindset means students should hit fewer errors overall.
What it usually means: Typo in .append(). Student wrote .apend() with one 'p'. Very common.
How to fix: Spell append with two 'p's: animals.append("dog"). Variants: .appned(), .appendix() โ all the same fix.
What it usually means: Student wrote animals = animals.append("dog") โ they assigned the return value of .append() back to animals. But .append() returns None, so now animals IS None. The next iteration's append crashes.
How to fix: Don't assign the result. Just call the method: animals.append("dog") on its own line. The list updates in place.
What it usually means: Student wrote sort(animals) as a function. There's no top-level sort() function in Python โ it's sorted() with a 'd', or animals.sort() as a method.
How to fix: Use sorted(animals) if you want a new sorted list (this lesson's choice). Or animals.sort() if you want to sort in place. Don't mix the two.
What it usually means: The empty list animals = [] is INSIDE the for loop. It resets to [] at the start of every iteration. By the end, the list only contains the last appended item.
How to fix: Move animals = [] BEFORE the loop. Echo of Unit 2.3's counter-initialization bug. The rule: anything that should accumulate across iterations is initialized BEFORE, updated INSIDE, read AFTER.
What it usually means: The factorial loop's accumulator is initialized to result = 0. Then result = result * i is always 0 (anything ร 0 = 0).
How to fix: Initialize result = 1. The "do-nothing" identity for multiplication is 1, not 0. Same logic applied differently from Unit 2.3 counter (where 0 IS the right start because we ADD to it).
What it usually means: A student tries to sorted() a list with mixed types (some numbers, some strings). Python can't compare them.
How to fix: Make sure the list contains only one type. If users enter numbers via input(), wrap with int() before appending so all entries are integers. Or keep all as strings.
Watch list:
SyntaxError: expected ':'โ missing colon onfororifline. Same as Unit 1 & 2.IndentationErrorโ typically in the capstone where loops + if/else nest. Three-level indentation rules from Unit 2.3 still apply.NameErrorโ variable used before defined, or typo. Same as before.TypeError: '>' not supported between instances of 'str' and 'int'โ student forgot toint()-wrap input. Same as Unit 1 quotes-trap.- Infinite loop (no error) โ if a student keeps Unit 2's
whileloop wrapper around the new code and forgets to update the loop variable. Use the 3-step debugging strategy.
โ End of Unit 3 Teacher's Guide โ
