Abstraction (7a)

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Abstraction (7a)

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which statement best describes abstraction?
A Adding as many details as possible to the problem
B Keeping only the details needed to solve the problem
2. A map for a bus passenger shows bus routes and stops but not the colour of each house. This is an example of:
A Abstraction
B Validation
3. A school system stores a student's name, class and attendance. Which detail is probably irrelevant?
A The student's favourite colour
B The student's class
4. Why do programmers use abstraction when analysing a problem?
A To make the program take longer to write
B To focus on the important details and make the problem simpler
5. In a racing game, which detail is relevant to the game's rules?
A The speed of each car
B The brand of the player's keyboard

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1DECLARE StudentName : STRING AThe shoe colour is an irrelevant detail. A timetable needs only the lessons, times and rooms, so abstraction means leaving it out.
2// Ignore the trees and houses BScore ← Score + 10
3A game keeps the score because it matters, but ignores details that do not affect play CDECLARE BusStop : STRING
4A bus route program stores only the stops it needs and nothing about the bus colour DA school system keeps a detail it needs, such as a name, and leaves out details like favourite colour
5DECLARE ShoeColour : STRING // for a school timetable EA programmer decides which details to leave out because they do not help solve the problem
6// Map program: store every tree and every leaf FThis keeps far too much detail. Abstraction means keeping only useful details such as roads and landmarks and ignoring the rest.

Definitions

abstraction

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
// ___________ keeps only the needed details
2.
// Hair colour is not needed for the score DECLARE Score : _______
3.
// A map shows roads but not every tree ______ RoadName
4.
// A school system keeps only needed data _______ StudentName : STRING
5.
// Only price and quantity matter here Total ← Price _ Quantity

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A # Bus map: only useful data
B DECLARE StopName : STRING
C DECLARE StopNumber : INTEGER
D OUTPUT StopName, StopNumber
Question 2
A // Report: only needed details
B DECLARE StudentName : STRING
C DECLARE ShoeSize : INTEGER
D INPUT StudentName
E INPUT Mark
Question 3
A DECLARE Score : INTEGER
B DECLARE Lives : INTEGER
C Score ← 0
D Lives = 3
E // Sky colour is not tracked
Question 4
A DECLARE RoadName : STRING
B DECLARE Distance : DECIMAL
C INPUT RoadName
D INPUT Distance
Question 5
A INPUT PlayerName
B INPUT PlayerScore
C OUTPUT PlayerName, AvatarColour
D // Leaderboard ignores avatar

Answer Key

Abstraction (7a)
Section A: Quick Questions
Q1
B — Keeping only the details needed to solve the problem
Q2
A — Abstraction
Q3
A — The student's favourite colour
Q4
B — To focus on the important details and make the problem simpler
Q5
A — The speed of each car
Section B: Match the Pairs
Q1
DECLARE StudentName : STRING → A school system keeps a detail it needs, such as a name, and leaves out details like favourite colour
Q2
// Ignore the trees and houses → A programmer decides which details to leave out because they do not help solve the problem
Q3
A game keeps the score because it matters, but ignores details that do not affect play → Score ← Score + 10
Q4
A bus route program stores only the stops it needs and nothing about the bus colour → DECLARE BusStop : STRING
Q5
DECLARE ShoeColour : STRING // for a school timetable → The shoe colour is an irrelevant detail. A timetable needs only the lessons, times and rooms, so abstraction means leaving it out.
Q6
// Map program: store every tree and every leaf → This keeps far too much detail. Abstraction means keeping only useful details such as roads and landmarks and ignoring the rest.
Section C: Definitions
Q1
abstraction — Keeping only the details needed to solve a problem and leaving out the details that do not matter, e.g. a map shows roads but not every tree.
Section D: Fill in the Blanks
Q1
// Abstraction keeps only the needed details
Q2
// Hair colour is not needed for the score DECLARE Score : INTEGER
Q3
// A map shows roads but not every tree OUTPUT RoadName
Q4
// A school system keeps only needed data DECLARE StudentName : STRING
Q5
// Only price and quantity matter here Total ← Price * Quantity
Section E: Spot the Error
Q1
A — Comments in Cambridge pseudocode start with //, not #. It should be // Bus map: only useful data. The program also shows abstraction: a bus map stores stop names and numbers but not details like tree colour.
Q2
C — Shoe size is an irrelevant detail for a report system, and Mark is now never declared. Abstraction keeps only what is needed, so line 3 should be DECLARE Mark : INTEGER.
Q3
D — Assignment in Cambridge pseudocode uses the ← arrow, not =. Line 4 should be Lives ← 3. The game tracks only Score and Lives and ignores details like sky colour.
Q4
B — DECIMAL is not a Cambridge data type. A distance with decimal places should be declared as REAL, so line 2 should be DECLARE Distance : REAL.
Q5
C — The leaderboard only needs the name and score. Avatar colour is an irrelevant detail that abstraction leaves out, and it was never input. Line 3 should output PlayerName, PlayerScore.