Python Generators Quiz
FREE Online Courses: Dive into Knowledge for Free. Learn More!
Quiz Summary
0 of 10 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 10 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 10
1. Question
What keyword is used to define a generator?
CorrectIncorrect -
Question 2 of 10
2. Question
What object is created when a generated is called?
CorrectIncorrect -
Question 3 of 10
3. Question
What keyword is used instead of return in while creating generators?
CorrectIncorrect -
Question 4 of 10
4. Question
Suppose we are printing a sequence of 10 integers using a generator. If each integer occupies four bytes, then how many total bytes are used by the end of the program.
CorrectIncorrect -
Question 5 of 10
5. Question
How many minimum yields statements should there be in a generator?
CorrectIncorrect -
Question 6 of 10
6. Question
What is the output of the below code?
def generator_x():
num = 1
while num < 5:
if num % 2 == 0:
yield num
num += 1
print(next(generator_x()))
CorrectIncorrect -
Question 7 of 10
7. Question
What is the output of the below code?
Code
def generator_a():
num = 1
while True:
yield num
print(next(generator_a()), next(generator_a()))
CorrectIncorrect -
Question 8 of 10
8. Question
What is the output of the below code?
Code
def generate():
a = 5
while a:
yield a
a -= 1
for b in generate():
print(b, end=” “)
CorrectIncorrect -
Question 9 of 10
9. Question
What is the output of the below code?
Code
print(list((pow(i, 2) for i in range(1, 5))))
CorrectIncorrect -
Question 10 of 10
10. Question
What is the output of the below code?
Code
var = (i for i in range(1))
next(var)
print(next(var))
CorrectIncorrect