1/15
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Syntax Error
Occurs when Python encounters code that violates its syntax rules.
Example of Syntax Error
print("Hello World") - The closing quote is missing.
Indentation Error
Occurs when the code is not properly indented, breaking Python’s strict indentation rules for blocks.
Example of Indentation Error
for i in range(5): print(i) - The print statement should be indented under the for loop.
Name Error
Happens when a variable or function is used before it is defined.
Example of Name Error
print(myvariable) - myvariable is not defined before it is used.
Type Error
Raised when an operation is performed on incompatible data types.
Example of Type Error
result = 5 + "10" - Cannot add an integer (5) and a string ("10").
Attribute Error
Occurs when a non-existent attribute is accessed on an object.
Example of Attribute Error
text = "Hello"; text.append(" World") - Strings do not have an append() method.
Value Error
Happens when a function receives an argument of the correct type but an inappropriate value.
Example of Value Error
number = int("Hello") - The string "Hello" cannot be converted to an integer.
Index Error
Occurs when trying to access an element of a list or tuple that is out of range.
Example of Index Error
mylist = [1, 2, 3]; print(mylist[3]) - The list has only three elements (indices 0, 1, and 2).
Import Error
Occurs when an imported module cannot be found or cannot be loaded.
Example of Import Error
import nonexistentmodule - The specified module does not exist.