ベータこのプラットフォームは活発に開発中です。バグ、未実装の機能、データ消失のリスクがあります。応援ありがとうございます!

Identifying Errors

遊んで学ぼう

問題に答えてエネルギーを集めたら、釣りや探検を楽しもう。アカウント不要。

先生の方へ: Identifying Errors(Computer Science、CIE)向けのすぐ使えるレッスンスライド, 復習ノート — レッスンで使うか、生徒がライブゲームとして遊ぶインタラクティブなクラス活動としてトピックを実施できます。

レッスンノート

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.

スライド

Sign up free to view the lesson slides

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

練習問題

無料プレビュー — 59問中8問。すべて見るには登録を。
  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

無料アカウントを作って、このトピックのすべての問題・スライド・フラッシュカード・復習ノートを見よう。

過去問

このトピックの過去問練習は近日公開。
近日公開