1/14
Vocabulary flashcards covering 15 common coding errors, each with a concise definition and illustrative example.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Off-by-One Error (OBOE)
Loop or index goes one step too far or stops one step early; e.g., using <= instead of < in a for-loop.
Index Error
Attempt to access an element outside the valid range of a list, array, or string; e.g., my_list[10] when the list has only five items.
Type Error
Operation performed on incompatible data types; e.g., trying to add a string and an integer: '3' + 4.
Syntax Error
Code violates the language’s grammar rules; e.g., forgetting the colon in an if statement: if x == 5
Indentation Error (Python)
Code block is indented incorrectly, breaking Python’s structure; often caused by mixing tabs and spaces.
Name Error
Using a variable or function name that has not been defined; e.g., print(undeclared_variable).
Infinite Loop
Loop whose exit condition is never met, so it never terminates; e.g., while True: without a break.
Logical Error
Code executes without crashing but produces wrong results; e.g., using or instead of and in a condition.
Mutation of Mutable Defaults (Python)
Using a mutable object (like a list or dict) as a default function argument, causing shared state across calls; e.g., def f(x, my_list=[]):
Shadowing Built-ins
Redefining variable names that conflict with Python’s built-in functions, hiding the original; e.g., list = [1, 2, 3].
Case Sensitivity Issue
Referencing the same identifier with different capitalization, creating distinct names; e.g., myVar vs myvar.
Missing Return Statement
Function performs work but omits return, implicitly returning None, leading to unexpected results.
Unreachable Code
Statements placed after return, break, or other terminating keywords that will never execute.
Incorrect Boolean Logic
Conditional expression that always evaluates the same way due to misuse of operators; e.g., if x == 1 or 2: is always True.
Incorrect Use of is vs == (Python)
Using is (identity comparison) when == (equality comparison) is intended; e.g., if a is b instead of if a == b.