ProceduralOCR J277
DashboardCoursePracticeReviewProgressGlossary
Saved on this deviceContinue learning

Procedural · OCR J277 programming practice

Progress stays in this browser unless you export it.

Course/Robust programs/Syntax, runtime and logic errors
J277 · 2.3.2

Unit 10 · Lesson 4

Syntax, runtime and logic errors

Lesson progress0 / 7

Build the idea

Start with the concept and its key vocabulary.

Key idea

Distinguish syntax, runtime and logic errors and refine a program to remove them.

A syntax error breaks the rules of the language, such as a missing Python colon. A runtime error happens after execution starts, such as dividing by zero. A logic error lets the program finish but gives the wrong result. Testing and careful tracing help locate logic errors because the translator cannot identify an incorrect intention. Refinement then improves the solution: fix faults, remove repetition, improve names or comments, use sub-programs and add required functionality.

Syntax error

An error that breaks language grammar and prevents the program from running or being translated.

Runtime error

An error that stops a program after execution has begun.

Logic error

An error where the program runs but produces incorrect or unexpected output.

Debugging

Finding, understanding and correcting errors in a program.

Refinement

Improving an algorithm after design and testing so it is more correct, readable, efficient or useful.

Keep these in mind

  • A syntax definition must mention broken language rules, not only one example.
  • Runtime errors begin execution and then stop it.
  • Logic errors produce incorrect or unexpected results without necessarily crashing.
  • Wrong variables, operators, loop bounds and incomplete conditions commonly cause logic errors.
  • Refinement includes fixing faults, improving readability or efficiency and adding required functionality.

Learning objective

Distinguish syntax, runtime and logic errors and refine a program to remove them.

Exam tip

Use precise definitions: 'prevents execution because language grammar is broken' for syntax; 'runs but produces incorrect output' for logic.

Common mistake

'The program does not work' is too vague. State whether it cannot start, stops during execution or completes with the wrong result.

PreviousNext