Year 10 · Computer Science · Summer 1
Software · Lesson 5 of 5
Programming practice: a scenario question
Exam practice7.9 Writing and amending algorithms8.2 Arrays
Year 10 · Computer Science · Software · Lesson 5 of 5
You will learn to
- Plan a 15-mark scenario question in ten minutes: a numbered task list, the arrays and the variables.
- Write the solution in fifteen minutes, with meaningful names and comments.
- Test the solution in five minutes against the task list.
- Use the mark scheme to find the requirements you met and the ones you missed.
Year 10 · Computer Science · Software · Lesson 5 of 5
Success criteria
You have got it when you can say:
- I can turn a scenario into a numbered checklist of tasks.
- I can write a solution that uses an array, a loop and validation.
- I can mark my answer with the scheme and name one requirement I missed.
Year 10 · Computer Science · Software · Lesson 5 of 5
Retrieval starter
Questions from before. Write your answers, then show them.
- Last lesson
An interpreter stops…
A Only after translating everythingB NeverC At the first error it meets
C. At the first error it meets
- Last unit
17 MOD 5 is…
A 3.4B 3C 2
C. 2
- Earlier this year
The ALU does…
A Fetching instructionsB Storing filesC Arithmetic and logic
C. Arithmetic and logic
Year 10 · Computer Science · Software · Lesson 5 of 5
Key words (1 of 4)
- Algorithm
- A precise, ordered set of steps that solves a problem.
- Program development life cycle
- The four stages of making a program: analysis, design, coding and testing.
- Structure diagram
- A top-down diagram that shows how a system is split into sub-systems.
- Pseudocode
- A structured, code-like way of writing an algorithm that is not tied to one language.
Year 10 · Computer Science · Software · Lesson 5 of 5
Key words (2 of 4)
- Totalling
- Keeping a running total by adding each value to a total variable.
- Counting
- Adding 1 to a counter variable each time something happens.
- Bubble sort
- Sorting by comparing neighbouring items and swapping them if they are in the wrong order, pass after pass.
Year 10 · Computer Science · Software · Lesson 5 of 5
Key words (3 of 4)
- Validation
- An automatic check that input data is reasonable and follows set rules.
- Check digit
- An extra digit calculated from the other digits, used to catch typing errors.
- Variable
- A named place in memory whose value can change while the program runs.
- Identifier
- The name given to a variable, constant, array or subroutine.
Year 10 · Computer Science · Software · Lesson 5 of 5
Key words (4 of 4)
- Data type
- The kind of value stored: INTEGER, REAL, CHAR, STRING or BOOLEAN.
- Selection
- Choosing which statements to run using a condition (IF or CASE).
- Iteration
- Repeating a block of statements in a loop.
- Array
- A data structure holding many values of the same data type under one name, each found by its index.
7.9 Writing and amending algorithms · The explanation · step 1 of 9 · part 1 of 5
Be precise, and amend with care
An algorithm must say exactly what to do. 'More than 50' is `> 50`. '50 or more' is `>= 50`. These give different results for 50.
Set every total, counter, highest and lowest to a start value before the loop. Use meaningful names like `PassCount`, not `x`, and `//` comments.
An amend question asks you to change a given algorithm. Find the line that controls the behaviour and change only that line.
7.9 Writing and amending algorithms · The explanation · step 1 of 9 · part 2 of 5
Be precise, and amend with care (continued)
Example: to make the bubble sort give descending order (largest first), change `>` to `<` in the comparison.
| Words in the question | Pseudocode |
|---|---|
| over 18 / more than 18 | `Age > 18` |
| 18 or over / at least 18 | `Age >= 18` |
| under 18 / less than 18 | `Age < 18` |
| between 1 and 21 inclusive | `Days >= 1 AND Days <= 21` |
| not equal to -1 | `Value <> -1` |
7.9 Writing and amending algorithms · The explanation · step 1 of 9 · part 3 of 5
Be precise, and amend with care (continued)
// Original: sorts into ascending order (smallest first) IF Numbers[Index] > Numbers[Index + 1] // Amended: sorts into descending order (largest first) IF Numbers[Index] < Numbers[Index + 1]
7.9 Writing and amending algorithms · The explanation · step 1 of 9 · part 4 of 5
Be precise, and amend with care (continued)
numbers = [7, 3, 9, 2, 5]
top = 5
swap = True
while swap == True and top > 1:
swap = False
for index in range(top - 1):
# amended: < instead of > gives descending order
if numbers[index] < numbers[index + 1]:
temp = numbers[index]
numbers[index] = numbers[index + 1]
numbers[index + 1] = temp
swap = True
top = top - 1
print(numbers)7.9 Writing and amending algorithms · The explanation · step 1 of 9 · part 5 of 5
Be precise, and amend with care (continued)
Rewriting the whole algorithm wastes time and can add new errors. The examiner is looking for the one or two key changes.
`Days >= 1 AND <= 21` is wrong. Write the variable on both sides: `Days >= 1 AND Days <= 21`.
7.9 Writing and amending algorithms · The explanation · step 2 of 9 · part 1 of 3
The 15-mark scenario question: plan first
The last question on Paper 2 is a scenario worth 15 marks. Allow about 30 minutes. You may answer in pseudocode, Python, Visual Basic or Java.
Read the scenario twice. Underline every task. Make a numbered checklist and tick each item as you code it.
Sample scenario: a teacher records three tests for each of 30 students. Each test is out of 50. Names are already in `StudentName[1:30]`.
7.9 Writing and amending algorithms · The explanation · step 2 of 9 · part 2 of 3
The 15-mark scenario question: plan first (continued)
7.9 Writing and amending algorithms · The explanation · step 2 of 9 · part 3 of 3
The 15-mark scenario question: plan first (continued)
Marks are given for meeting each requirement. A checklist stops you forgetting one, which is the most common way to lose marks here.
7.9 Writing and amending algorithms · The explanation · step 4 of 9 · part 1 of 4
How the 15 marks are awarded
Recent mark schemes use levels, not one mark per line. AO2 (applying techniques and data structures) gives up to 9 marks. AO3 (comments, identifiers, logic and accuracy) gives up to 6 marks.
The examiner reads the whole answer and picks the band that fits best. Minor syntax errors are ignored if the logic is clear.
7.9 Writing and amending algorithms · The explanation · step 4 of 9 · part 2 of 4
How the 15 marks are awarded (continued)
| Band | AO2: techniques and data structures (9) | AO3: comments, names, accuracy (6) |
|---|---|---|
| Top | 7–9: all tasks covered with the right techniques; arrays store all the data | 5–6: fully commented, meaningful names, logical and accurate, meets all requirements |
| Middle | 4–6: some techniques suit the problem; some data stored correctly | 3–4: some comments, most names sensible, most requirements attempted |
| Low | 1–3: at least one technique used; some data stored, not well | 1–2: no useful comments, some sensible names, at least one requirement attempted |
7.9 Writing and amending algorithms · The explanation · step 4 of 9 · part 3 of 4
How the 15 marks are awarded (continued)
7.9 Writing and amending algorithms · The explanation · step 4 of 9 · part 4 of 4
How the 15 marks are awarded (continued)
Because marks come in bands, a working answer to every task beats a perfect answer to half of them. Attempt every requirement, even if one part is rough.
The explanation · 6 more steps
More on the lesson page
The lesson page has the rest of the explanation, step by step:
- Model answer in pseudocode and Python
- What an array is
- Using a variable as the index
- 2D arrays: rows and columns
- Nested loops to visit every element
- Initialising a 2D array
Year 10 · Computer Science · Software · Lesson 5 of 5
Quick quiz · 1 of 3
An IDE provides…
- A An editor, a run button and a debugger
- B Only the keyboard
- C The operating system
A. An editor, a run button and a debugger
Integrated development environment: everything for writing code in one app.
Year 10 · Computer Science · Software · Lesson 5 of 5
Quick quiz · 2 of 3
Which of these is system software?
- A A word processor
- B A game
- C The operating system
C. The operating system
System software runs the computer. Applications do jobs for people.
Year 10 · Computer Science · Software · Lesson 5 of 5
Quick quiz · 3 of 3
The bootloader…
- A Translates Python
- B Prints documents
- C Loads the operating system from storage into RAM at start-up
C. Loads the operating system from storage into RAM at start-up
It lives in ROM and runs first when the power comes on.
Year 10 · Computer Science · Software · Lesson 5 of 5
Exit ticket
Answer on paper before you go. Then check.
An interrupt is…
A A signal that makes the CPU pause and deal with somethingB A type of virusC A loop that never ends
A. A signal that makes the CPU pause and deal with something A key press or a printer out of paper. The CPU saves its place, handles it, carries on.
A compiler…
A Only checks spellingB Translates the whole program once into machine codeC Translates one line at a time, every run
B. Translates the whole program once into machine code It produces an executable file. Errors are reported at the end.
Year 10 · Computer Science · Software · Lesson 5 of 5
Homework and the challenge
Homework
The CS 4 quiz.
End-of-unit challenge
End-of-unit test: past-paper questions on topic 4, plus the scenario question.