Year 9 · Summer 2
Raid: Capstone · Lesson 3 of 5
Build sprint 2
ProjectTopic 14 Programming further
Year 9 · Raid: Capstone · Lesson 3 of 5
You will learn to
- Use the log to plan the sprint, building the must-have criteria first.
- Join the parts of the project together and test that they work as one.
- Demonstrate the project to another guild and record their feedback.
- Update the log with what changed after the demo.
Year 9 · Raid: Capstone · Lesson 3 of 5
Success criteria
You have got it when you can say:
- I can show which success criteria already work and which do not yet.
- I can join my part to a teammate's part and test them together.
- I can write down two stars and one wish from the other guild.
Year 9 · Raid: Capstone · Lesson 3 of 5
Retrieval starter
Questions from before. Write your answers, then show them.
- Last lesson
open("log.txt", "w") on a file that already holds 100 lines…
A Adds to the endB Gives an errorC Wipes it first
C. Wipes it first
- Last unit
Which is an embedded system?
A A tabletB A laptopC The computer controlling a car's airbags
C. The computer controlling a car's airbags
- Earlier this year
To show change over time, use a…
A Scatter graphB Line chartC Pie chart
B. Line chart
Year 9 · Raid: Capstone · Lesson 3 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 3 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
Plan the sprint from the log
Start with the stand-up. Read your last log entry: it says what comes next.
Sort what is left into must and nice. A must-have is in the success criteria. A nice extra is not.
Build every must-have first. A nice extra waits until every criterion works.
The explanation · step 2 of 3 · part 1 of 2
Join the parts
Parts that work alone can still break when they meet. Joining them is called integration.
score = 0
name = input("What is your name? ")
score = score + ask("101", 5)
score = score + ask("1000", 8)
# … 8 more questions …
print(name, "scored", score, "out of 10")
file = open("scores.txt", "a") # "a" adds to the end of the file
file.write(name + "," + str(score) + "\n")
file.close()The explanation · step 2 of 3 · part 2 of 2
Join the parts (continued)
name + "," + score crashes, because score is a number. Turn it into text first with str(score).
After joining, run the whole program from start to end. Then test each part again.
The explanation · step 3 of 3
The mid-point demo
Halfway through, show the project to another guild. It is not finished yet, and that is fine.
- Say the brief and the user in one sentence.
- Show what works, criterion by criterion.
- Say honestly what does not work yet.
- Listen. The other guild gives two stars and a wish.
Write the feedback in your log. Decide as a guild what to change. You do not have to change everything.
Year 9 · Raid: Capstone · Lesson 3 of 5
Worked example (1 of 2)
Omar's save part worked alone. After joining, the program crashes on file.write(name + "," + score + "\n"). Why, and what is the fix?
- Read the error: 'can only concatenate str (not "int") to str'.
- Concatenate means join pieces of text together. Python will not join text and a number.
- In Omar's own test, he typed score = "7", which is text. After joining, score comes from ask(), which returns a number.
- Fix: write
str(score). It turns the number into text.
Year 9 · Raid: Capstone · Lesson 3 of 5
Worked example (2 of 2)
Omar's save part worked alone. After joining, the program crashes on file.write(name + "," + score + "\n"). Why, and what is the fix?
- Run the whole program again. Check that scores.txt has a new line, like Ana,7.
Year 9 · Raid: Capstone · Lesson 3 of 5
Quick quiz · 1 of 3
word = "Python". What is word[1:4]?
- A "yth"
- B "ytho"
- C "Pyth"
A. "yth"
Start at index 1 (y), stop before index 4 (o): y, t, h. That's 4 − 1 = 3 characters.
Year 9 · Raid: Capstone · Lesson 3 of 5
Quick quiz · 2 of 3
In def area(w, h): … and a = area(4, 3), which are the arguments?
- A w and h
- B 4 and 3
- C area and a
B. 4 and 3
Arguments are the actual values passed in the call. w and h are parameters.
Year 9 · Raid: Capstone · Lesson 3 of 5
Quick quiz · 3 of 3
A variable made inside a function is…
- A Saved to a file
- B Global: usable anywhere
- C Local: only exists inside it while it runs
C. Local: only exists inside it while it runs
Local variables are wiped when the function returns.
Year 9 · Raid: Capstone · Lesson 3 of 5
Exit ticket
Answer on paper before you go. Then check.
Testing a 0–50 range with 50 is…
A Boundary dataB Normal dataC Erroneous data
A. Boundary data It's right at the edge of what's allowed.
Typing your new password twice so they can be compared is…
A ValidationB VerificationC Authentication
B. Verification Verification checks data was entered correctly. Double entry is one method.