GATE DA Python OOP, Modules & Exception Handling | Set 1

Questions 91-95 of 100

0% completed (0/100 answered)
Your score 0/100 0 answered
Correct 0 Incorrect 0 Unanswered 100 Accuracy 0%

Question 91

MCQ · Single Correct 1 mark

Which pair of dunder methods must an object implement to satisfy the Iterator Protocol in Python?

Answers for question 91

Question 92

NAT · Numerical Answer 1 mark
PYTHON
Evaluate:
def double_dec(func):
 def wrapper(x):
 return func(x) * 2
 return wrapper

def inc_dec(func):
 def wrapper(x):
 return func(x) + 1
 return wrapper

@double_dec
@inc_dec
def calc(x):
 return x

print(calc(5))

Answers for question 92

Question 93

MCQ · Single Correct 1 mark

What happens when calling raise without arguments inside an except block?

Answers for question 93

Question 94

NAT · Numerical Answer 1 mark
PYTHON
What is the output?
def test():
 try:
 raise ValueError('err')
 except ValueError:
 return 1
 except Exception:
 return 2
 else:
 return 3

print(test())

Answers for question 94

Question 95

MCQ · Single Correct 1 mark

Which built-in exception is the base class for all non-exit built-in exceptions in Python?

Answers for question 95
Scroll to Top