Common Coding Errors to Learn and Avoid

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/14

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards covering 15 common coding errors, each with a concise definition and illustrative example.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

15 Terms

1
New cards

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.

2
New cards

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.

3
New cards

Type Error

Operation performed on incompatible data types; e.g., trying to add a string and an integer: '3' + 4.

4
New cards

Syntax Error

Code violates the language’s grammar rules; e.g., forgetting the colon in an if statement: if x == 5

5
New cards

Indentation Error (Python)

Code block is indented incorrectly, breaking Python’s structure; often caused by mixing tabs and spaces.

6
New cards

Name Error

Using a variable or function name that has not been defined; e.g., print(undeclared_variable).

7
New cards

Infinite Loop

Loop whose exit condition is never met, so it never terminates; e.g., while True: without a break.

8
New cards

Logical Error

Code executes without crashing but produces wrong results; e.g., using or instead of and in a condition.

9
New cards

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=[]):

10
New cards

Shadowing Built-ins

Redefining variable names that conflict with Python’s built-in functions, hiding the original; e.g., list = [1, 2, 3].

11
New cards

Case Sensitivity Issue

Referencing the same identifier with different capitalization, creating distinct names; e.g., myVar vs myvar.

12
New cards

Missing Return Statement

Function performs work but omits return, implicitly returning None, leading to unexpected results.

13
New cards

Unreachable Code

Statements placed after return, break, or other terminating keywords that will never execute.

14
New cards

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.

15
New cards

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.