ExamVeda
Login
Home
11
What is the purpose of the assert statement in Python?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
12
The following Python code will result in an error if the input value is entered as -5.
assert False, 'Spanish'
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
13
What is the purpose of the except clause in a try block?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
14
What is the output of the following code:
try:
x = 10 / 0
except ZeroDivisionError:
print("Error!")
finally:
print("Finally!")
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
15
Which of the following is not an exception handling keyword in Python?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
16
What is the purpose of the else clause in a try block?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
17
What is the purpose of the finally clause in a try block?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
18
How can you create a custom exception class in Python?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
19
What is the syntax to raise an exception manually in Python?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
20
What will be the output of the following Python code?
def getMonth(m):
    if m<1 or m>12:
        raise ValueError("Invalid")
    print(m)
getMonth(6)
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board