Year 9 · Summer 2
Raid: Capstone · Lesson 2 of 5
Build sprint 1
ProjectTopic 14 Programming further
Year 9 · Raid: Capstone · Lesson 2 of 5
You will learn to
- Use a stand-up to say what you did, what you will do and what is blocking you.
- Create your part of the project in small steps, testing after each one.
- Write a log entry with what you did, what went wrong and what comes next.
Year 9 · Raid: Capstone · Lesson 2 of 5
Success criteria
You have got it when you can say:
- I can give my stand-up update in about 30 seconds.
- I can show my part working at the end of the lesson, even if it is small.
- I can write a log entry that a teammate could follow.
Year 9 · Raid: Capstone · Lesson 2 of 5
Retrieval starter
Questions from before. Write your answers, then show them.
- Last lesson
Testing a 0–50 range with 50 is…
A Erroneous dataB Normal dataC Boundary data
C. Boundary data
- Last unit
The numbers 3, 9, 4, 4, 10. What is the median?
A 4B 9C 6
A. 4
- Earlier this year
Which makes a password hardest to crack?
A Adding ! at the endB Adding lengthC Swapping o for 0
B. Adding length
Year 9 · Raid: Capstone · Lesson 2 of 5
Key words (1 of 2)
- List
- One name holding many values in order. Also called an array.
- Index
- An item's position in a list, counting from 0.
- Subroutine
- A named block of code you can call when needed.
- Function
- A subroutine that returns a value.
Year 9 · Raid: Capstone · Lesson 2 of 5
Key words (2 of 2)
- Parameter
- A placeholder in a subroutine for a value passed in.
- Validation
- Checking input is reasonable before using it.
- Boundary data
- Test data at the very edge of what's allowed.
The explanation · step 1 of 3 · part 1 of 2
Sprints and stand-ups
A sprint is a short, fixed block of time. The team builds the parts it chose for that sprint.
Each sprint starts with a stand-up: a quick meeting where everyone stands, so it stays short. Each person answers three questions:
- What did I do last time?
- What will I do today?
- What is blocking me?
The explanation · step 1 of 3 · part 2 of 2
Sprints and stand-ups (continued)
A blocker is anything that stops you: a bug, a missing part, or a question.
Speak for about 30 seconds each. Solve problems after the stand-up, not during it.
Then the guild asks for one mini-lesson on what it is stuck on. Good requests: 'How do we keep asking until the input is valid?' 'How do we read a sensor every second?'
The explanation · step 2 of 3 · part 1 of 3
Build in small steps: an example
Leo owns 'reject bad input and ask again'. He builds and tests it on its own first.
def get_number(prompt):
while True:
text = input(prompt).strip() # strip() removes spaces at each end
if text.isdigit() and int(text) <= 255:
return int(text) # valid: hand the number back
print("Please type a whole number from 0 to 255.")
print(get_number("What is 101 in denary? "))The explanation · step 2 of 3 · part 2 of 3
Build in small steps: an example (continued)
while True:keeps asking, until areturnends the function.isdigit()is True only if every character is a digit. A blank, '-1' or 'five' gives False.int(text) <= 255checks the range. Python only checks it ifisdigit()was True.- The last line is a quick test. Leo deletes it once the part works.
The explanation · step 2 of 3 · part 3 of 3
Build in small steps: an example (continued)
Test each small step at once. Type 5, then 255, then 256, then a blank, then 'five'.
The explanation · step 3 of 3
Keep the log
At the end of every sprint, each person writes a short log entry.
| Lesson | What I did | Problem | Next |
|---|---|---|---|
| 2 | get_number works for 5, 0 and 255 | '5 ' with a space was rejected. Fixed with strip(). | Join it to Ana's question function |
Why log?
Next lesson you know where to start. In lesson 5 your evaluation needs evidence, and the log is that evidence.
Year 9 · Raid: Capstone · Lesson 2 of 5
Worked example
Ana writes ask(binary, answer). It must use Leo's get_number, and return 1 for a right answer and 0 for a wrong one. How does it work?
- Ana's function takes two parameters: the binary number to ask about, and the right answer.
- It calls
get_number("What is " + binary + " in denary? ")to get a valid number from the player. - If
guess == answer, it prints 'Correct!' and returns 1. - If not, it prints the right answer and returns 0.
- So the main program can write
score = score + ask("101", 5). The score goes up by 1 for each right answer.
Year 9 · Raid: Capstone · Lesson 2 of 5
Quick quiz · 1 of 3
Typing your new password twice so they can be compared is…
- A Validation
- B Authentication
- C Verification
C. Verification
Verification checks data was entered correctly. Double entry is one method.
Year 9 · Raid: Capstone · Lesson 2 of 5
Quick quiz · 2 of 3
open("log.txt", "w") on a file that already holds 100 lines…
- A Wipes it first
- B Adds to the end
- C Gives an error
A. Wipes it first
"w" empties the file before writing. Use "a" to append.
Year 9 · Raid: Capstone · Lesson 2 of 5
Quick quiz · 3 of 3
The program runs but gives the wrong answer. That's a…
- A Syntax error
- B Runtime error
- C Logic error
C. Logic error
The code is valid and doesn't crash; the thinking is wrong. Only testing finds it.
Year 9 · Raid: Capstone · Lesson 2 of 5
Exit ticket
Answer on paper before you go. Then check.
Program runs but gives the wrong answer. That's a…
A Logic errorB Syntax error
A. Logic error The code is valid; the thinking is wrong.
In ["a", "b", "c"], the index of "c" is…
A 2B cC 3
A. 2 Counting starts at 0: a = 0, b = 1, c = 2.