Gateway python types of error

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/44

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 1:57 AM on 9/11/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

45 Terms

1
New cards

What is a SyntaxError?

A SyntaxError occurs when Python cannot understand the code because it violates Python's syntax rules.

2
New cards

What is the easiest way to remember SyntaxError?

Think: "Python can't understand how I wrote the code."

3
New cards

What is a common SyntaxError in an if statement?

Forgetting the colon after the condition. Example: if x > 5 instead of if x > 5:.

4
New cards

What error occurs if you write if x = 5:?

SyntaxError. Use == to compare values: if x == 5:.

5
New cards

What error can occur if you use invalid Python syntax?

SyntaxError.

6
New cards

What is a NameError?

A NameError occurs when Python tries to use a name or variable that has not been defined.

7
New cards

What is the easiest way to remember NameError?

Think: "Python doesn't know this name."

8
New cards

What happens if you print a variable before assigning it?

Python raises a NameError because the variable has not been defined yet.

9
New cards

What happens if you misspell a variable name?

A NameError can occur if the misspelled name has not been defined.

10
New cards

Are Python variable names case-sensitive?

Yes. x and X are different variable names.

11
New cards

What happens with x = 10 followed by print(X)?

NameError, because X and x are different names and X was never defined.

12
New cards

What is a TypeError?

A TypeError occurs when an operation is performed using an inappropriate type.

13
New cards

What is the easiest way to remember TypeError?

Think: "I'm using the wrong type."

14
New cards

What happens when you try "hello" + 5?

TypeError. Python cannot directly concatenate a string and an integer using +.

15
New cards

What is a ValueError?

A ValueError occurs when a function receives a value that is inappropriate even though the value has an acceptable general type.

16
New cards

What is the easiest way to remember ValueError?

Think: "The type is okay, but the value is not."

17
New cards

What happens when int("hello") is executed?

ValueError, because "hello" cannot be converted into an integer.

18
New cards

What is an IndentationError?

An IndentationError occurs when Python's indentation is incorrect.

19
New cards

Why is indentation especially important in Python?

Indentation determines code blocks, such as the statements inside if, elif, else, while, and for.

20
New cards

What can happen if you forget to indent the body of an if statement?

Python can raise an IndentationError because the statements belonging to the if block must be indented.

21
New cards

What is a ZeroDivisionError?

A ZeroDivisionError occurs when a program attempts to divide by zero.

22
New cards

What happens when 10 / 0 is executed?

ZeroDivisionError.

23
New cards

What happens when 10 // 0 is executed?

ZeroDivisionError.

24
New cards

What happens when 10 % 0 is executed?

ZeroDivisionError.

25
New cards

What is a logical error?

A logical error occurs when the code runs but produces an incorrect result because the programmer's logic is wrong.

26
New cards

What is the easiest way to remember a logical error?

Think: "Python runs it, but I got the wrong answer."

27
New cards

What is an example of a logical error in a conditional?

Using > when the problem requires <, causing the program to choose the wrong branch.

28
New cards

What is an off-by-one error?

A logical error where a loop runs one time too many or one time too few.

29
New cards

What commonly causes an off-by-one error in range()?

Forgetting that range() excludes its stop value.

30
New cards

What is an infinite loop?

A loop that continues indefinitely because its condition never becomes false or because the loop is otherwise never stopped.

31
New cards

Is an infinite loop necessarily a SyntaxError?

No. An infinite loop can be a logical error because the code can be valid Python but never terminate.

32
New cards

What commonly causes an infinite while loop?

Failing to update the variable that controls the while condition so the condition never becomes false.

33
New cards

What is the difference between SyntaxError and NameError?

SyntaxError means Python cannot understand the code's syntax; NameError means Python cannot find a defined name or variable.

34
New cards

What is the difference between NameError and TypeError?

NameError means a name has not been defined; TypeError means an operation is being performed with an inappropriate type.

35
New cards

What is the difference between TypeError and ValueError?

TypeError means the type is inappropriate; ValueError means the type is acceptable but the value itself is inappropriate.

36
New cards

What is the difference between a Python error and a logical error?

A Python error such as SyntaxError or TypeError causes Python to report a problem, while a logical error can allow the program to run while producing the wrong result.

37
New cards

What should you do when you see an error in a quiz code-tracing question?

Find the line causing the problem, identify what Python rule was violated, and determine the error type.

38
New cards

Which error means Python cannot understand the way the code is written?

SyntaxError.

39
New cards

Which error means a variable or name has not been defined?

NameError.

40
New cards

Which error means an inappropriate type was used?

TypeError.

41
New cards

Which error means an inappropriate value was used even though the type is acceptable?

ValueError.

42
New cards

Which error means the indentation is incorrect?

IndentationError.

43
New cards

Which error means the program attempted to divide by zero?

ZeroDivisionError.

44
New cards

Which error means the program runs but gives the wrong result because the logic is incorrect?

Logical error.

45
New cards

What are the seven error concepts most important to know for these Gateway Python topics?

SyntaxError, NameError, TypeError, ValueError, IndentationError, ZeroDivisionError, and logical errors.