Words You Own
Second advisory, back into code. You are not starting over — you already used all eight of these in a program that ran. Click a word, then click its meaning. Eight pairs, three points each. A wrong pair costs one point, so read first.
Words
Meanings
Spot It In Code
A word you can define but cannot find is a word you do not own yet. Click the exact piece of the line being described. Four questions, five points each. One shot each.
Turtle Toolbox
1.1.4 asks you to build a spirograph. You cannot do it with .forward()
and .right() alone. Here is the whole toolbox — this table is open while you work.
| Method | What it does |
|---|---|
| .forward(d) | Moves the turtle d pixels in the direction it is already facing. |
| .backward(d) | Moves d pixels opposite the way it is facing. The turtle does not turn around. |
| .right(a) | Turns right a degrees. Does not move. |
| .left(a) | Turns left a degrees. Does not move. |
| .setheading(h) | Points the turtle at an absolute heading, 0 to 360. Not a turn — a reset. |
| .heading() | Hands back the heading it is facing right now. Note the empty parentheses. |
| .goto(x, y) | Moves straight to the coordinate x, y. |
| .xcor() · .ycor() | Hands back the turtle's current x or y. You will use .ycor() as a loop condition in 1.1.4. |
| .circle(r) | Draws a full circle of radius r. The centre is r pixels to the turtle's left. |
| .circle(r, a) | Draws only an arc, a degrees of that circle. |
| .circle(r, a, s) | Draws that arc in s straight steps, so you get a polygon instead of a curve. |
| .dot(s) | Drops a filled dot of diameter s. No movement, no turn. |
| .stamp() | Stamps a copy of the turtle's own shape where it stands. |
| .penup() | Lifts the pen. Move now and nothing is drawn. |
| .pendown() | Puts the pen back down so drawing resumes. |
| .pensize(s) | Sets line thickness to s. |
| .pencolor(c) | Sets the line colour. c is a string: "red". |
| .fillcolor(c) | Sets the inside colour for the next filled shape. |
| .begin_fill() | Call it before you draw the shape you want filled. |
| .end_fill() | Call it after. Miss this and nothing fills. |
| .speed(s) | Speed 0 to 10. .speed(0) is instant — you will want it for spirographs. |
| .shape(s) | "arrow", "turtle", "circle", "square", "triangle", "classic". |
| .turtlesize(s) | Scales the turtle sprite itself, not the drawing. |
| .hideturtle() · .showturtle() | Hides or shows the sprite. The drawing stays either way. |
painter.circle(50), painter
is the object, .circle is the method, and
50 is the parameter. Object on the left of the dot, action on the right,
instructions inside the parentheses. Every line in 1.1.4 reads that way.Toolbox drill
Four questions, four points each. Scroll up to the table — using it is the point.
New Words — Predict First
These eight words are the whole of Activity 1.1.4. You have not been taught them yet. That is on purpose. Guess from the word itself and from code you have already written. Nothing here is marked right or wrong. Your pick locks in purple, and Section 5 shows you what it actually means.
The Reveal
Here is what those eight words actually mean, and the two that will cost you a class period if you get them wrong. Two scored checks at the bottom, six points each.
1 · Relational operator & Boolean
A relational operator compares two values. It does not store anything and it does not do math.
It hands back a Boolean — one of exactly two values, True or
False. There is no third option.
| Python | Reads as | College Board writes it |
|---|---|---|
| == | is equal to | a = b |
| != | is not equal to | a ≠ b |
| > | is greater than | a > b |
| < | is less than | a < b |
| >= | is greater than or equal to | a ≥ b |
| <= | is less than or equal to | a ≤ b |
= is a
command: put the right side into the left side. == is a question:
are these two the same? On the AP exam the College Board writes equality as a single =.
In Python that single = would assign instead of compare. Two different pens, same symbol.2 · The while loop
A for loop runs a number of times you already know. A while loop keeps going as long as a condition stays True — and you may not know how many times that will be. Same four parts every time: the keyword, the condition, the colon, and an indented body.
Trace it yourself
Each click is one trip through the loop. Watch the condition get checked before the body runs, every single time.
| count | count < 5 | body runs? | count after |
|---|
What the turtle draws
Five circles, 72° apart. Five times 72 is 360 — the same rule you used on the flower.
REPEAT UNTIL (condition), which keeps going until the condition becomes
True. A Python while keeps going while the condition
is True and stops when it turns False. Same idea, inverted condition. Translating one to the
other means flipping it.3 · Infinite loop
An infinite loop is a loop whose condition never becomes False. It does not crash. It does not error. It just runs forever, and you have to kill the program yourself. Here is PLTW's example:
The increment is there, so what went wrong? line % 2 is a remainder after dividing
by 2, so it can only ever be 0 or 1. It can never equal
2. So != 2 is True forever.
The loop was doomed by the condition, not by a missing line.
4 · Zero-iteration condition
The opposite failure. A zero-iteration condition is false the very first time it is checked, so the body never runs even once. No error, no output, and students stare at a blank screen thinking the program broke.
Both failures come from the same place: the relationship between where the counter starts and what the condition asks. Check that relationship before you run, every time.
5 · Nested loop
A nested loop is a loop inside another loop. Every single time the outer loop goes around once, the inner loop runs all the way to completion.
So j prints 1 through 5, and it does that ten times over. Multiply the loops to get
the total: ten times five is fifty. This is how a few lines of code draws a thousand-line spirograph.
6 · Operator precedence
Operator precedence is the fixed order Python evaluates arithmetic in. Parentheses first, then exponents, then multiply / divide / modulo, then add / subtract.
Watch it resolve
Same numbers. Different answers.
Those two expressions use the same digits in nearly the same order and land on
24 and 0. One % changed everything, because it
sits in the same precedence tier as * and / and just
took its turn in line.
The dot operator — the . in
painter.right(5) — resolves after parentheses but before any of the math
operators. And parentheses always win, so use them when you want to be certain.
7 · Flowcharts: algorithms without code
You can write an algorithm with no programming language at all. A flowchart uses an oval for begin and end, a rectangle for a command, and a diamond for a decision. A linear algorithm has one path start to finish; a conditional one branches on a True/False question.
That diamond is the loop condition, and the arrow going back up is the iteration. A while loop is this picture.
8 · Decidable or undecidable
A decidable problem is one you can write an algorithm for that gives a correct answer for
every possible input. "Is this number even?" is decidable — num % 2 == 0
settles it, always.
An undecidable problem is one where no algorithm can always give a correct yes-or-no answer. Some individual cases may be solvable; there is just no single algorithm that handles all of them. The classic example is the one you just met: given a program and an unknown input, will it ever stop running? If the input comes from a user you do not know, you cannot decide it in advance.
Check your predictions
Ungraded. This only shows you which of your eight guesses landed.
Scored checks
Launch Check
Seven questions, four points each. Pass this and you are ready to open 1.1.4 and start building a spirograph. One shot per question, and a wrong answer tells you what to go re-read.