
Python comprehensions, generators, and exceptions
Quiz
•
Computers
•
9th - 12th Grade
•
Practice Problem
•
Hard
Erik Nielsen
Used 6+ times
FREE Resource
Enhance your content in a minute
28 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The code to the left can be written more compactly as
a = 'hi' if x = 3 else 'there'
a = if x == 3: 'hi' else: 'there'
a = 'hi' if x == 3 else 'there'
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The code to the left can be written more compactly as
b = line if ('H' in line) else ''
b = line if 'H' in line
b = if 'H' in line: line else: ''
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the result of the following statement?
print([i.upper() for i in "hello"])
[‘H’, ‘E’, ‘L’, ‘L’, ‘O’]
‘HELLO’
[‘HELLO’]
HELLO
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What datatype is x after the following statements?
a = [1, 2, 3]
x = [2*i for i in a]
list
tuple
dictionary
generator
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What datatype is x after the following statements?
a = ['hello', 3.14, 7]
x = {i: 10 for i in a}
list
tuple
dictionary
generator
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the result of the following statement?
print([i if i%2==0 else i+1 for i in range(4)])
[0, 2, 2, 4]
[1, 1, 3, 3]
error
none of the mentioned
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which list comprehension will pick out only negative integers from a given list ‘a’?
[x<0 in a]
[x for x<0 in a]
[x in a for x<0]
[x for x in a if x<0]
Create a free account and access millions of resources
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
24 questions
Одновимірні масиви ІІ семестр
Quiz
•
11th Grade
26 questions
11 ինֆորմատիկա Համացանց
Quiz
•
11th Grade
25 questions
HTML
Quiz
•
11th Grade
30 questions
Quiz Herramientas TIC
Quiz
•
12th Grade
25 questions
Kuis AP (Var, If, Looping)
Quiz
•
11th Grade
23 questions
PRACTICE ABOUT II TEST COMPUTER SKILLS
Quiz
•
10th Grade
23 questions
free tes PAS PBO PPLG
Quiz
•
9th - 12th Grade
23 questions
Tin học
Quiz
•
10th Grade
Popular Resources on Wayground
25 questions
Multiplication Facts
Quiz
•
5th Grade
15 questions
4:3 Model Multiplication of Decimals by Whole Numbers
Quiz
•
5th Grade
10 questions
The Best Christmas Pageant Ever Chapters 1 & 2
Quiz
•
4th Grade
12 questions
Unit 4 Review Day
Quiz
•
3rd Grade
20 questions
Christmas Trivia
Quiz
•
6th - 8th Grade
18 questions
Kids Christmas Trivia
Quiz
•
KG - 5th Grade
14 questions
Christmas Trivia
Quiz
•
5th Grade
15 questions
Solving Equations with Variables on Both Sides Review
Quiz
•
8th Grade
Discover more resources for Computers
40 questions
Introduction to Microsoft Word
Quiz
•
8th - 12th Grade
85 questions
Word Processing Review
Quiz
•
8th - 9th Grade
11 questions
Internet Terms Vocabulary- Notebook Check #1- CTEA
Quiz
•
12th Grade
39 questions
UNIT 7 and UNIT 8 — Multiple Choice Question Bank (Extracted)
Quiz
•
9th Grade
31 questions
Python Conditionals Review
Quiz
•
9th - 12th Grade
