Choosing data types and loops, evaluating expressions, and decomposition
Watch the whole lecture free
Make a free account to watch every lecture to the end: 5 practice questions, 2 real past-paper questions with the answers explained, the mistakes that lose marks, the full-marks tip, a one-card summary and a quick quiz.
That was the teaching part. The rest of this lecture is free with an account: 5 practice questions, 2 real past-paper questions with the answers explained, the mistakes that lose marks, the full-marks tip, a one-card summary and a quick quiz.
No password needed now: we email you a link to set one. Already have an account? Sign in, then come back to this page.
The teaching part (1 min) is free to watch. A free account opens the whole lecture: 5 practice questions, 2 real past-paper questions with the answers explained, the mistakes that lose marks, the full-marks tip, a one-card summary and a quick quiz.
What this lecture covers
- The right tool for each job
- The data types
- Choosing the type
Read the transcript of the teaching part
Last time
Before we start: last time, in Arrays, searching, bubble sort and records, you learned these points. Here they are again on one card. Keep them in mind, because today builds on them.
The right tool for each job
A postcode, a price, a yes or no. Each needs a different type. A set of repeats, a wait for input, a list to process. Each needs a different loop. Choose well and the program is correct and clear. Choose badly and it fails on awkward data. And a big problem becomes manageable once you break it into modules, each with one clear job.
The data types
INTEGER holds whole numbers. REAL holds numbers with a decimal part. CHAR holds one character. STRING holds text of any length. BOOLEAN holds TRUE or FALSE. DATE holds a calendar date. Choose by what the data is used for, not by what it looks like.
Choosing the type
Number of members: INTEGER, because you cannot have half a member. Fee per hour: REAL, because it has pence. A telephone number: STRING, not an integer. It may start with 0, and you never do arithmetic on it. A postcode: STRING, since it has letters. Is the member active: BOOLEAN. Date of joining: DATE. Membership grade A, B or C: CHAR.
How often it comes up
How often Cambridge has asked each part, counted by ExamYard from every past paper in its question bank: Choosing the right loop.
The whole chapter: Programming Fundamentals.
Chapter 11: Programming
- Pseudocode constructs: IF, CASE, records and arrays 6 min
- Choosing data types and loops, evaluating expressions, and decomposition 5 min
- Finding errors in statements, following algorithms, good practice and identifier tables 6 min
Also for A Level Computer Science 9618
Which topics come up most in A Level Computer Science 9618 past papers, counted from every paper since 2004: Paper 1 topic frequency, Paper 2 topic frequency.