PCEP-30-02 practice question 20 of 35
What is the output of the following code snippet if the user enters a 0? try: val = input('Enter a value: ') print(int(val) / len(val)) except…
Choose your answer, then check it against the explanation.
Domain Functions and Exceptions
What is the output of the following code snippet if the user enters a 0?
try:
val = input('Enter a value: ')
print(int(val) / len(val))
except ZeroDivisionError:
print('ZeroDivisionError raised...')
except:
print('Bad input...')
Question 20 of 35
Keep practicing
Take the free PCEP-30-02 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other PCEP-30-02 practice questions
- Question 1The following list is given:
- Question 2What is the output of the following code? num = 10 while num >= 0: num -= 2 print(num)
- Question 4We need to check if at least one element of the iterable object evaluates to the truth. W…
- Question 5This question is a tricky one. What is the result of the following code snippet? numbers …
- Question 8What is the purpose of the continue statement in Python?
- Question 11We need to check if all elements of the iterable object evaluate to the truth. What built…
