Identify common errors
2.1.2 Designing, creating and refining algorithms
Practise exam questionsDesigning, creating and refining algorithms — Note 6 of 7
Identify syntax/logic errors in code and suggest fixes
When writing or reading algorithms, you need to be able to identify two types of error: syntax errors and logic errors. Syntax errors break the rules of the programming language and stop the program from running. Logic errors allow the program to run but produce incorrect or unexpected results. Being able to spot and fix both is a key programming skill.
printt), missing brackets, missing quotation marks, incorrect indentation, using =< instead of <=.num1 + num1 instead of num1 + num2), incomplete conditions, wrong loop bounds, wrong operator.Breaks the rules/grammar of the programming language; prevents the program from running/executing.
The program runs but produces incorrect/unexpected results/output.
# SYNTAX ERROR - missing closing bracket
# print("Hello World"
# LOGIC ERROR - wrong formula
distance = 100
time = 20
speed = time / distance # Should be distance / time
print(speed) # Outputs 0.2 instead of 5.0Ready to test yourself?
Practise 2.1.2 questionsBack to Designing, creating and refining algorithms
Revise another OCR GCSE topic: Searching and sorting algorithms, Computational Thinking