feat(curriculum): add Python error handling quiz (#60600)

Co-authored-by: Dario-DC <105294544+Dario-DC@users.noreply.github.com>
Co-authored-by: Krzysztof G. <60067306+gikf@users.noreply.github.com>
Co-authored-by: Jessica Wilkins <67210629+jdwilkin4@users.noreply.github.com>
This commit is contained in:
Kolade Chris
2025-08-06 14:44:21 +01:00
committed by GitHub
parent 6bf3e33b69
commit 0eb04d9aed

View File

@@ -7,7 +7,7 @@ dashedName: quiz-error-handling
# --description--
To pass the quiz, you must correctly answer at least 18 of the 20 questions below.
To pass the quiz, you must correctly answer at least 9 of the 10 questions below.
# --quizzes--
@@ -17,439 +17,225 @@ To pass the quiz, you must correctly answer at least 18 of the 20 questions belo
#### --text--
Placeholder question
What will be the output of this code?
```py
try:
print(22 / 0)
except ZeroDivisionError:
print("You can't divide by zero!")
```
#### --distractors--
Placeholder distractor 1
`22`
---
Placeholder distractor 2
`10`
---
Placeholder distractor 3
`0`
#### --answer--
Placeholder answer
`You can't divide by zero!`
### --question--
#### --text--
Placeholder question
Which module of the Python standard library lets you debug your code in an interactive way?
#### --distractors--
Placeholder distractor 1
ABC
---
Placeholder distractor 2
numpy
---
Placeholder distractor 3
debugpy
#### --answer--
Placeholder answer
pdb
### --question--
#### --text--
Placeholder question
Which exception does Python raise when you try to use a method or attribute that does not exist for that type?
#### --distractors--
Placeholder distractor 1
`SyntaxError`
---
Placeholder distractor 2
`AttributeBug`
---
Placeholder distractor 3
`SyntaxBug`
#### --answer--
Placeholder answer
`AttributeError`
### --question--
#### --text--
Placeholder question
Which Python statement can you insert around various points in your code so you can see the values of variables while debugging?
#### --distractors--
Placeholder distractor 1
`len()`
---
Placeholder distractor 2
`console()`
---
Placeholder distractor 3
`log()`
#### --answer--
Placeholder answer
`print()`
### --question--
#### --text--
Placeholder question
Which statement lets you manually raise an exception?
#### --distractors--
Placeholder distractor 1
`if`
---
Placeholder distractor 2
`throw`
---
Placeholder distractor 3
`from`
#### --answer--
Placeholder answer
`raise`
### --question--
#### --text--
Placeholder question
Which error will the code `print("Hello world"` raise in your Python code?
#### --distractors--
Placeholder distractor 1
It would not raise any error.
---
Placeholder distractor 2
`ValueError`
---
Placeholder distractor 3
`NameError`
#### --answer--
Placeholder answer
`SyntaxError`
### --question--
#### --text--
Placeholder question
What does `try...except` let you do in Python?
#### --distractors--
Placeholder distractor 1
It provides a way to test your code interactively.
---
Placeholder distractor 2
It lets you write mathematical expressions.
---
Placeholder distractor 3
It speeds up testing.
#### --answer--
Placeholder answer
It lets you execute a block of code that might raise an exception.
### --question--
#### --text--
Placeholder question
Which object lets you access the exception itself for better debugging and direct printing of the error message?
#### --distractors--
Placeholder distractor 1
Debugger Object
---
Placeholder distractor 2
Traceback Object
---
Placeholder distractor 3
BugFinder Object
#### --answer--
Placeholder answer
Exception Object
### --question--
#### --text--
Placeholder question
Which of the following optional clauses can be added to a `try...except` statement?
#### --distractors--
Placeholder distractor 1
`if` and `else`
---
Placeholder distractor 2
`elif` and `if`
---
Placeholder distractor 3
`else` and `elif`
#### --answer--
Placeholder answer
`else` and `finally`
### --question--
#### --text--
Placeholder question
Which block of a `try` statement runs whether an error occurs or not?
#### --distractors--
Placeholder distractor 1
`else`
---
Placeholder distractor 2
`except`
---
Placeholder distractor 3
`try`
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
### --question--
#### --text--
Placeholder question
#### --distractors--
Placeholder distractor 1
---
Placeholder distractor 2
---
Placeholder distractor 3
#### --answer--
Placeholder answer
`finally`