Time allowed: 45 minutes
| Centre number |
| | | |
|
Candidate number |
| | | |
| First name |
|
Last name |
INSTRUCTIONS
- Use black ink.
- Answer all the questions.
INFORMATION
- The total mark for this paper is 29.
- The marks for each question are shown in brackets [ ].
Turn over
Section A: Core Definitions
1
(a) Define the term
Syntax Error.
[1]
(b) Define the term
Logic Error.
[1]
(c) A programmer is writing a game in a High-Level Language (Python).
(i) When is a Syntax Error usually detected? (Choose one: During writing/translation OR While the program is running).
[1]
(ii) When is a Logic Error usually detected?
[1]
Section B: Syntax Spotting
2
The following code is intended to ask for a user's age and print it next year. It contains
three Syntax Errors.
01 age = input("Enter your age: ")
02 next_age = age + 1
03 if next_age >= 18
04 Print("You are an adult next year")
05 else:
06 print("You are a minor")
Identify the line number and write the correction for each of the three syntax errors.
[6]
Error 1: Line ........... Correction: ....................................................................................
Error 2: Line ........... Correction: ....................................................................................
Error 3: Line ........... Correction: ....................................................................................
Turn over
Section C: Logic Errors & "Ghost Topics"
3
A programmer writes a while loop to count down from 10 to 1. The program runs, but the screen fills with 10 forever and never stops.
01 count = 10
02 while count > 0:
03 print(count)
04 # End of loop
(a) State the name of the logical error occurring here (specifically regarding the loop).
[1]
(b) Explain why this error is occurring based on the code above.
[2]
(c) Write the one line of code that is missing and needs to be added inside the loop to fix this.
[2]
4
A theme park ride allows people to enter if they are
Over 12 years old OR
Taller than 140cm.
The programmer writes the following algorithm:
01 age = 10
02 height = 150
03 if age > 12 and height > 140:
04 print("Allowed")
05 else:
06 print("Denied")
(a) Determine the output of the current algorithm.
[1]
(b) The output in part (a) is a Logic Error. Explain why the result is incorrect based on the rules of the theme park.
[2]
(c) Refine line 03 to correct the logic error.
[2]
Turn over