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

Questions 86-90 of 100

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

Question 86

NAT · Numerical Answer 1 mark
PYTHON
What is the output of the following Python code?
def my_dec(func):
 def wrapper(a, b):
 return func(a, b) + 10
 return wrapper

@my_dec
def add(a, b):
 return a + b

print(add(3, 4))

Answers for question 86

Question 87

MCQ · Single Correct 1 mark

What keyword is used in a function to transform it into a Generator function?

Answers for question 87

Question 88

NAT · Numerical Answer 1 mark

Evaluate the output:
def gen():
yield 1
yield 2
yield 3

$g = gen()
print(next(g) + next(g) \cdot 10)$

Answers for question 88

Question 89

MCQ · Single Correct 1 mark

What exception is raised when a generator or iterator has no more items to yield during a next() call?

Answers for question 89

Question 90

NAT · Numerical Answer 1 mark

What is the output of:
def fib_gen(limit):
a, b = 0, 1
while a < limit:
yield a
a, $b = b, a + b

print(sum(fib_gen(10)))$

Answers for question 90
Scroll to Top