BÊTACette plateforme est en développement actif ; des bugs, des fonctionnalités manquantes et un risque de perte de données sont possibles. Merci pour ton soutien !

Identifying Errors

Apprends en jouant

Réponds à ces questions pour gagner de l'énergie, puis pêche et explore. Sans compte.

Pour les profs : diapos de leçon, notes de révision prêts à l'emploi pour Identifying Errors (Computer Science, CIE) — utilise-les en cours, ou lance le thème en activité de classe interactive que tes élèves jouent en direct.

Notes de leçon

Types of Errors

  • Three main categories: syntax errors, logic errors, and runtime errors.
  • Syntax errors break grammatical rules of the programming language and prevent the program from running.
  • Logic errors cause the program to run but produce incorrect output.
  • Runtime errors cause the program to crash during execution.
  • Trace tables help identify all types of errors by simulating program execution.

Syntax Errors

  • Examples: missing brackets, misplaced semicolons, typos in variable names, incorrect operator use.
  • Example: `def generateusername(firstname, lastname)` missing colon (`:`) at end.
  • Example: `firstname = imput(...)` misspelling `input` as `imput`.
  • Example: `usdrname = ...` typo in variable name.
  • Example: `main` missing parentheses `()` to call the function.

Logic Errors

  • Program runs but gives wrong results due to flawed logic.
  • Examples: incorrect comparison operators (`<` instead of `≤`), using `AND` instead of `OR`, off-by-one loops, array index errors.
  • Example: `if length < 0 or width < 0:` should be `≤ 0` to reject zero as non-positive.
  • Logic errors are often found using trace tables and test data.

Runtime Errors

  • Errors that occur during program execution, causing a crash.
  • Examples: division by zero, array index out of bounds, file not found, type conversion failure.
  • Example: entering `"abc"` for a float input crashes without a loop to retry.
  • Fix: wrap input in a `while True` loop with try-except to handle invalid input gracefully.

Using Trace Tables

  • A trace table records the state of variables at each step of algorithm execution.
  • Helps detect logic errors by comparing expected vs actual outcomes.
  • Each column represents a variable; each row shows values after a line of code.
  • Useful for dry-running algorithms in exams.

Writing & Amending Algorithms

  • Algorithmic thinking uses abstraction and decomposition to break problems into steps.
  • Plan algorithm in parts: declare variables, input, process, loop, output.
  • Use variable names and data exactly as given in the question to avoid losing marks.
  • Comment code to explain logic and help examiners award marks.
  • Pseudocode has no strict syntax, but follow IGCSE specification for consistency.

Exam Tips

  • Describe syntax errors as 'prevents the program from running'.
  • Describe logic errors as 'produces incorrect output'.
  • Describe runtime errors as 'causes the program to crash'.
  • Name the error type, locate it, and explain its impact on output/execution.
  • Use scrap paper to draft algorithms before writing final answer.

Diapos

Sign up free to view the lesson slides

Step through every slide for this topic — plus flashcards and revision notes — with a free account.

Questions d'entraînement

Aperçu gratuit — 8 sur 59 questions. Inscris-toi pour toutes les voir.
  1. 1.Which type of error prevents a program from running?

    Easy
    • ASyntax error
    • BLogic error
    • CRuntime error
    • DOff-by-one error
  2. 2.Which type of error causes a program to crash while it is running?

    Easy
    • ASyntax error
    • BLogic error
    • CRuntime error
    • DCompilation error
  3. 3.A program runs but produces an incorrect result. What type of error is most likely present?

    Easy
    • ASyntax error
    • BLogic error
    • CRuntime error
    • DInput error
  4. 4.Which of the following is an example of a syntax error?

    Easy
    • AUsing a variable before it is assigned
    • BDividing by zero
    • CMissing a colon at the end of a function definition
    • DAn array index going out of bounds
  5. 5.In the following pseudocode, what type of error is present? FOR i ← 1 TO 10 OUTPUT i NEXT i (Assume the loop should output numbers 1 to 10, but it outputs 1 to 11.)

    Medium
    • ASyntax error
    • BLogic error
    • CRuntime error
    • DNo error
  6. 6.Which of the following is NOT a common type of error in programming?

    Easy
    • ASyntax error
    • BLogic error
    • CRuntime error
    • DDesign error
  7. 7.A programmer writes: IF age > 18 THEN OUTPUT 'Adult' ELSE OUTPUT 'Child'. The program always outputs 'Child' even when age is 20. What type of error is this?

    Medium
    • ASyntax error
    • BLogic error
    • CRuntime error
    • DTypo error
  8. 8.A program crashes when the user enters a string instead of a number. This is an example of a:

    Easy
    • ASyntax error
    • BLogic error
    • CRuntime error
    • DCompilation error

Unlock all 59 questions & more

Crée un compte gratuit pour voir toutes les questions, les diapos, les cartes mémo et les notes de révision de ce thème.

Annales

Les annales d'entraînement pour ce thème arrivent bientôt.
Bientôt disponible