Skip to the page
Year 9 · Summer 2 · Raid: Capstone

Build sprint 1

What this lesson covers

Topic 14 Programming further

KS3 Computing · Real programs keep data in lists, take text apart as strings, split work into subroutines, check their input, save to files, and get tested on purpose.

Programming Computational ThinkingCambridge Lower Secondary Computing 0860

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.

Success criteria

  • 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.

Key words

Say each word, then read what it means. Every one is in the glossary too.

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.
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

Read it here, or open the study page below to go one step at a time with things to try.

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:

  1. What did I do last time?
  2. What will I do today?
  3. What is blocking me?

A blocker is anything that stops you: a bug, a missing part, or a question.

★Remember

Speak for about 30 seconds each. Solve problems after the stand-up, not during it.

e.g.Example

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?'

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? "))
  1. while True: keeps asking, until a return ends the function.
  2. isdigit() is True only if every character is a digit. A blank, '-1' or 'five' gives False.
  3. int(text) <= 255 checks the range. Python only checks it if isdigit() was True.
  4. The last line is a quick test. Leo deletes it once the part works.
★Remember

Test each small step at once. Type 5, then 255, then 256, then a blank, then 'five'.

Keep the log

At the end of every sprint, each person writes a short log entry.

LessonWhat I didProblemNext
2get_number works for 5, 0 and 255'5 ' with a space was rejected. Fixed with strip().Join it to Ana's question function
?Why?

Why log?

Next lesson you know where to start. In lesson 5 your evaluation needs evidence, and the log is that evidence.

e.g.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?

  1. Ana's function takes two parameters: the binary number to ask about, and the right answer.
  2. It calls get_number("What is " + binary + " in denary? ") to get a valid number from the player.
  3. If guess == answer, it prints 'Correct!' and returns 1.
  4. If not, it prints the right answer and returns 0.
  5. So the main program can write score = score + ask("101", 5). The score goes up by 1 for each right answer.

Study it

Open the study page and go one step at a time.

Check yourself

One question at a time. The reason shows after each answer.

Saved on this device.