Python Generators

Quiz
•
Computers
•
10th Grade - University
•
Medium
Dr Sonia Mitchell
Used 52+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
True
False
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 Quizizz
12 questions
APCSA Unit 7

Quiz
•
9th - 12th Grade
10 questions
DATA STRUCTURES

Quiz
•
12th Grade
15 questions
Stack

Quiz
•
University
15 questions
Queues

Quiz
•
11th Grade - Professi...
10 questions
AP CSP - Python Lists and Arrays

Quiz
•
9th - 12th Grade
10 questions
Introduction to Java

Quiz
•
University
10 questions
Stack

Quiz
•
University
12 questions
Data Structures

Quiz
•
University
Popular Resources on Quizizz
15 questions
Multiplication Facts

Quiz
•
4th Grade
20 questions
Math Review - Grade 6

Quiz
•
6th Grade
20 questions
math review

Quiz
•
4th Grade
5 questions
capitalization in sentences

Quiz
•
5th - 8th Grade
10 questions
Juneteenth History and Significance

Interactive video
•
5th - 8th Grade
15 questions
Adding and Subtracting Fractions

Quiz
•
5th Grade
10 questions
R2H Day One Internship Expectation Review Guidelines

Quiz
•
Professional Development
12 questions
Dividing Fractions

Quiz
•
6th Grade
Discover more resources for Computers
25 questions
Spanish preterite verbs (irregular/changed)

Quiz
•
9th - 10th Grade
67 questions
Course Recap Ptho May25

Quiz
•
University
10 questions
Juneteenth: History and Significance

Interactive video
•
7th - 12th Grade
8 questions
"Keeping the City of Venice Afloat" - STAAR Bootcamp, Day 1

Quiz
•
9th - 12th Grade
20 questions
Distance, Midpoint, and Slope

Quiz
•
10th Grade
20 questions
Figurative Language Review

Quiz
•
10th Grade
20 questions
Understanding Linear Equations and Slopes

Quiz
•
9th - 12th Grade
6 questions
Railroad Operations and Classifications Quiz

Quiz
•
University