Python Generators

Quiz
•
Computers
•
10th Grade - University
•
Medium
Dr Sonia Mitchell
Used 52+ times
FREE Resource
10 questions
Show all answers
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is the generator expression?
[x**2 for x in my_list]
(x**2 for x in my_list)
{x**2 for x in my_list}
x**2 for x in my_list
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following Python code?
my_list = [1, 3, 6, 10]
list_ = [x**2 for x in my_list]
generator = (x**2 for x in my_list)
print(list_)
print(generator)
list object address and [1, 9, 36, 100]
[1, 9, 36, 100] and list object address
[1, 9, 36, 100] and generator object address
generator object address and [1, 9, 36, 100]
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following Python code?
my_list = [2, 4, 9, 14, 17]
value = sum(x**2 for x in my_list)
value
586
59
Error
Nothing is printed
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
A generator in Python makes use of ________ keyword.
Gen
Return
Yield
All the above
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Generator in Python is not a subclass of Iterator.
True
False
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
State whether the below statement is True or False.
issubclass(collections.Iterator,types.GeneratorType)
True
False
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
011_Technical Change Management-CompTIA Security+ SY0-701-1.3

Quiz
•
12th Grade - University
15 questions
list in python

Quiz
•
10th - 12th Grade
12 questions
GD2 - 4.12 C++ The Standard Template Library Test

Quiz
•
10th - 12th Grade
10 questions
DECISION MAKING IN C

Quiz
•
University
10 questions
Linear and Binary Search Algorithms

Quiz
•
11th Grade
13 questions
DS UNIT-2 TEST-2

Quiz
•
University
10 questions
Symbol Puzzle Recap

Quiz
•
12th Grade
7 questions
Final Practice

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
10 questions
Proper Keyboarding Techniques

Interactive video
•
6th - 10th Grade
10 questions
Understanding Computers: Hardware, Software, and Operating Systems

Interactive video
•
7th - 12th Grade
29 questions
AP CSP Unit 2 Review (Code.org)

Quiz
•
10th - 12th Grade