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

Questions 96-100 of 100

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

Question 96

NAT · Numerical Answer 1 mark
PYTHON
Consider:
def repeat(n):
 def dec(func):
 def wrapper(*args):
 return sum(func(*args) for _ in range(n))
 return wrapper
 return dec

@repeat(3)
def get_five():
 return 5

print(get_five())

Answers for question 96

Question 97

MCQ · Single Correct 1 mark

What is generator expression syntax in Python?

Answers for question 97

Question 98

NAT · Numerical Answer 1 mark

What is the output of:
gen_exp = (x**2 for x in range(5) if x % 2 == 1)
print(sum(gen_exp))

Answers for question 98

Question 99

MCQ · Single Correct 1 mark

What statement about yield from in Python generators is CORRECT?

Answers for question 99

Question 100

NAT · Numerical Answer 1 mark

What is the output of:
def sub_gen():
yield 10
yield 20

def main_gen():
yield from sub_gen()
yield 30

print(sum(main_gen()))

Answers for question 100
Scroll to Top