What will be the output of the following list comprehension? numbers = [1, 2, 3, 4, 5] squares = [x**2 for x in numbers]
Python List and Nested List Assessment

Quiz
•
Computers
•
12th Grade
•
Hard
Dhanalakshmi Murali
Used 2+ times
FREE Resource
30 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
[1, 4, 9, 16, 25]
[2, 4, 6, 8, 10]
[1, 2, 3, 4, 5]
[2, 4, 8, 16, 25]
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which list comprehension creates a list of even numbers from 1 to 10?
[x for x in range(1, 11) if x % 2 == 0]
[x for x in range(1, 11) if x % 2 != 0]
[x for x in range(2, 11, 2)]
[x * 2 for x in range(1, 6)]
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which list comprehension will convert all strings to uppercase?
[str.upper() for str in words]
[str.upper for str in words]
[str.upper(x) for x in words]
[x.upper() for x in words]
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of this list comprehension? [x*5 for x in [1,2,3]]
[5,1,2,3]
[1,2,3,1,2,3,1,2,3,1,2,3,1,2,3]
[[5,10,15]]
[5,10,15]
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What's the output of this list comprehension with conditional? [x if x > 2 else 0 for x in [1,2,3,4]]
[1, 2, 3, 4]
[0, 0, 3, 4]
[0, 2, 3, 4]
[1, 0, 3, 4]
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which list comprehension filters out non-numeric strings?
[x for x in ['1', 'a', '2', 'b'] if x.isnumeric()]
[x for x in ['1', 'a', '2', 'b'] if isinstance(x, int)]
[x for x in ['1', 'a', '2', 'b'] if type(x) == int]
[x for x in ['1', 'a', '2', 'b'] if x.isdigit]
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which list comprehension creates a list of vowels from a string?
[x for x in "hello world" if x in ['a','e','i','o','u']]
[x if x in 'aeiou' else '' for x in "hello world"]
[x for x in "hello world" where x in 'aeiou']
['aeiou' for x in "hello world"]
Create a free account and access millions of resources
Similar Resources on Quizizz
25 questions
UH PEMROGRAMAN DASAR 1

Quiz
•
10th - 12th Grade
27 questions
BJC AP CSP Unit 3 Exam Review

Quiz
•
9th - 12th Grade
25 questions
Algorithms - python (GCSE)

Quiz
•
10th - 12th Grade
25 questions
C++ arrays

Quiz
•
12th Grade
25 questions
CIW IBA Lesson 2 Vocabulary

Quiz
•
8th Grade - University
25 questions
CSD Unit 5, Chapter 1 Review

Quiz
•
6th - 12th Grade
35 questions
AP Computer Science Principles Practice Exam

Quiz
•
12th Grade
25 questions
C++ Programming Unit 3 Quiz

Quiz
•
10th - 12th Grade
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