Finding errors in statements, following algorithms, good practice and identifier tables
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
- Read it as the computer would
- Finding errors in statements
- Three statements
Read the transcript of the teaching part
Last time
Before we start: last time, in Choosing data types and loops, evaluating expressions, and decomposition, you learned these points. Here they are again on one card. Keep them in mind, because today builds on them.
Read it as the computer would
A computer does exactly what the code says, not what you meant. So the skill is to read each line literally: what type is this, what does it return, what happens next? With that habit you can spot errors, follow an algorithm line by line, and see why good layout and a clear identifier table matter before you write any code.
Finding errors in statements
The usual mistakes are about types. Joining a string and a number with a plus sign. Comparing a number with a character. Using a function with the wrong parameter. STR_TO_NUM of the string 27 plus 2 adds a string to an integer. The plus is applied before the conversion, so it is an error. The correct form converts first: STR_TO_NUM of 27, plus 2, gives 29.
Three statements
Statement two: MID of CPE1704TKS, starting at 4, length 2, gives 17. STR_TO_NUM turns it into the integer 17. No error. Statement three: MONTH of a date returns an integer. Comparing it with the character 6 mixes types. Error. In every answer, name the error: the types that clash, and where.
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.