-
Notifications
You must be signed in to change notification settings - Fork 1
Teaching Chapter IV
Teacher-facing notes for running Chapter IV in class.
| Sections | 9 (2 tutorials, 7 exercises) |
| Estimated time | 2 weeks for a mixed-ability Year 9 class (8 to 10 lessons) |
| Prerequisites | Chapters I, II, and III. Students need comfort with variables, loops, and the polygon formulas. |
| Live chapter | dbbudd.github.io/04.html |
Students leave able to: write if / else if / else statements, combine Boolean conditions using && and ||, classify triangles by side and by angle, classify quadrilaterals by their properties, and use the interactive Input() method to test their classifiers against many shapes without rewriting code.
The mathematics. Classification. Triangles by side (scalene, isosceles, equilateral) and by angle (acute, right, obtuse). Quadrilaterals and the hierarchy: square ⊂ rhombus ⊂ parallelogram, square ⊂ rectangle ⊂ parallelogram, etc. The triangle inequality (any two sides must sum to more than the third). The triangle angle sum theorem (interior angles sum to 180 degrees). Angle classification (acute, right, obtuse, straight, reflex).
The programming. if statements as branches in control flow. else if for multiple branches. else as the fallback. Boolean expressions: comparisons (==, <, >, <=, >=, !=) that evaluate to true or false. Logical operators: && (and), || (or), ! (not). Short-circuit evaluation. Compound conditions. De Morgan's laws. The Input() method in three variants: Input(number: 4, id: "sides"), Input(decimal: 1.5, id: "scale"), Input(text: "hello", id: "name").
Section 1 (If It's True) is the tutorial. Introduces if with a single condition, nothing else. The students see their first branch: "if this is true, do this; otherwise, do nothing." Keep it simple at this stage.
Section 2 (Classify an Angle) is the first application. Given an angle in degrees, classify it as acute, right, obtuse, straight, or reflex. This is where students first use else if to cover multiple cases. It also sneaks in Input(number: 90, id: "angle") as the way to get an input value, which is new and worth a full explanation.
Section 3 (Else If) is the second tutorial. Deepens the branch-handling and introduces the important concept of mutually exclusive branches. An else if chain only executes one branch: the first condition that matches. Order matters.
Sections 4 and 5 (Triangle Classifier, And and Or) bring in logical operators. Triangle Classifier uses a long if / else if chain to handle the six possible triangle types (scalene acute, scalene right, scalene obtuse, isosceles acute, isosceles right, isosceles obtuse, plus the degenerate equilateral which is always acute). And and Or introduces && and || explicitly with truth tables and De Morgan's laws. This is where Boolean logic stops being ad hoc and becomes a named topic.
Section 6 (Quadrilateral Checker) is the hardest section in the chapter. Given four side lengths and four angles, classify the quadrilateral. The hierarchy matters here: a square is a rhombus and a rectangle and a parallelogram, so the checker has to test for the most specific category first. We fixed a bug in this section during curriculum development where the rhombus check was unreachable because it came after the square check and duplicated its logic.
Section 7 (Right Angle Test) is a small exercise that uses the triangle inequality and the Pythagorean theorem. Given three side lengths, is the triangle right-angled? This previews Year 10 Pythagoras without making it the point.
Section 8 (Colour by Rule) is a visual exercise: draw a square, then colour it based on a rule ("if the side length is even, colour it red; otherwise colour it blue"). This is where conditionals meet drawing, and the result is a grid of differently coloured squares. We fixed a bug in this section during curriculum development where the pen colour was set on the wrong variable.
Section 9 (Polygon Properties) is the capstone. Given a number of sides, describe the polygon: is it convex, is it regular, what are the interior and exterior angles, what is the sum of interior angles, does it have lines of symmetry? This pulls together everything from Chapters III and IV.
The idea that order matters in an if / else if chain. This is the single most common bug in conditional logic at every level, from Year 9 to professional software engineering. A student who internalises "check the most specific case first, then the general case" will write cleaner code for the rest of their life.
The second thing, if you have time: De Morgan's laws. They're named, they're memorable, and they come up again and again in logic and set theory.
They aren't. A chain of separate if statements runs every branch that matches. A chain of if / else if runs only the first branch that matches. This matters enormously for classification.
Fix: show the broken version first. Have a student write a triangle classifier with three separate if statements (no else if). For an equilateral triangle, all three ifs succeed, and the student gets three classifications printed at once. Then rewrite with else if, and only one fires. The difference is visceral.
Students often write the quadrilateral classifier starting with "is it a parallelogram?" and then narrowing down. But Swift's if / else if runs the first match, so if you check "parallelogram" first, you never reach "rhombus" or "square". You have to check the most specific categories first: square, then rhombus, then rectangle, then parallelogram, then general quadrilateral.
Fix: draw the quadrilateral hierarchy as a tree on the board. Point out that the most specific categories are at the bottom. Then explain: "Swift reads top to bottom. The first match wins. So you have to put the bottom of the tree at the top of your code."
Students sometimes treat && and || as magic incantations that either work or don't. They don't develop an intuition for what each one does until they hit a truth table.
Fix: the And and Or section (5) contains truth tables. Draw them on the whiteboard before students see the code. Work through each combination by hand. Students who draw the truth tables themselves never forget them.
Students accept "angles in a triangle sum to 180" as a memorised fact without understanding why. This is a missed opportunity because the theorem has a beautiful proof using parallel lines (the same parallel line theorems from Chapter II's Letter Z section).
Fix: when the angle sum theorem comes up in section 4 or 6, briefly prove it using alternate interior angles. The proof takes 90 seconds and it ties Chapter II to Chapter IV in a way students appreciate.
Students misread the Input() method. The number: argument is the default value; the id: argument is the identifier for the interactive control. At runtime, the student can drag a slider to change the value, and the code uses whatever value they dragged to. The default is only what the slider starts at.
Fix: explicitly demo this. Show students a line like let sides = Input(number: 4, id: "sides"), then show them dragging the slider from 4 to 9 at runtime, then point out that the shape changes. The interactive part is the whole point.
Before section 5 (And and Or), start the lesson with 5 minutes of truth table drill on the whiteboard. No code, no Swift. Just "A and B, if A is true and B is true, the whole thing is ...". Make it call-and-response. Then show the Swift code.
Draw the full quadrilateral hierarchy on the whiteboard at the start of lessons on sections 6 and 9. It looks like:
Quadrilateral
/ | \
Parallelogram Trapezoid Kite
/ \
Rectangle Rhombus
\ /
Square
Keep it on the board for the whole lesson. Refer back to it when students write their classifier.
For at least two sections in this chapter (Triangle Classifier and Quadrilateral Checker), run a deliberately broken version with the branches in the wrong order. Show students the wrong output. Ask them to diagnose the problem before showing them the fix. The pain of seeing "square" classified as "rectangle" is the best teacher for "specific before general".
When you reach section 5, introduce De Morgan's laws by name and write them on the board:
NOT (A AND B) equals (NOT A) OR (NOT B)
NOT (A OR B) equals (NOT A) AND (NOT B)
Then work through a concrete example: "NOT (raining AND cold) equals (NOT raining) OR (NOT cold)". Students respond to concrete examples before abstract ones. The names are worth learning because they'll reappear in Year 11 logic and discrete maths at university.
Section 6: Quadrilateral Checker. Four reasons:
- The hierarchy is subtle and students have to internalise it.
- The branches must be in the correct order (most specific first).
- Each branch requires a compound condition combining side-length checks and angle checks.
- The code gets long (eight or nine branches).
How to teach it: split across two lessons. Lesson 1 is the hierarchy tree on the whiteboard, and students just label shapes by hand (no code). Lesson 2 is writing the checker, one branch at a time, in the correct order. Don't try to rush through it.
- A colour-by-number using conditionals. Classify regions of a drawing and colour them based on the classification. Good test of compound conditions.
- A calculator that checks for the Pythagorean triples. Given three inputs, classify as "right triangle", "obtuse", "acute", or "not a triangle". Uses the converse of the Pythagorean theorem, which is a Year 10 topic.
-
An interactive quadrilateral drawer. Use
Input(number:id:)to let the student vary the side lengths and angles interactively, and classify the result live. - De Morgan drills. Give students a compound condition and ask them to rewrite it using De Morgan's laws. Fast finishers who enjoy puzzles will love this.
When introducing if (section 1):
"Up to now, your code has run every line, top to bottom, every time. No choices. An
ifstatement lets the code make a choice. If something is true, do this. Otherwise, skip it."
When introducing else if chains (section 3):
"Swift reads your
if/else if/elsechain from top to bottom and stops at the first match. That means order matters. The most specific case goes first, the most general goes last."
When introducing Boolean operators (section 5):
"Most interesting conditions aren't just 'is this equal to that'. They're 'is A true AND B true'. That's what
&&does. Or 'is A true OR B true', which is what||does. Let's do a truth table so you can see exactly what each one means."
When introducing the quadrilateral hierarchy (section 6):
"A square is also a rhombus. And a rectangle. And a parallelogram. And a quadrilateral. It's all of them at once. When you write a classifier, you have to start with the most specific: is it a square? If not, is it a rhombus? And so on. If you start with 'is it a parallelogram', every square will be classified as a parallelogram and you'll never reach the square branch."
When introducing Input (section 2):
"So far, your code has been static: it runs the same way every time. The
Input()method lets you get a value from the reader interactively. You give it a default, and a name, and Swift Playgrounds creates a little slider the reader can drag. Let me show you."
Fill this section in after your first classroom run.
- Chapter IV on the live site
- Previous: Teaching Chapter III
- Next: Teaching Chapter V
- Up: Home
Geometry Playground · a Swift Playgrounds curriculum for high school geometry · dbbudd.github.io · built by Daniel Budd