Python List and Nested List Assessment

Python List and Nested List Assessment

12th Grade

30 Qs

quiz-placeholder

Similar activities

Unit 1 Primitive Types

Unit 1 Primitive Types

9th - 12th Grade

25 Qs

VOIP (TLJ) KELAS 12

VOIP (TLJ) KELAS 12

12th Grade

25 Qs

PLTW CSE Quiz - Activities 1.1.1 thru 1.1.3

PLTW CSE Quiz - Activities 1.1.1 thru 1.1.3

9th - 12th Grade

25 Qs

Data Types and Operators

Data Types and Operators

9th - 12th Grade

26 Qs

XII - CS - Lesson 9 - List and Tuple - Quiz 1

XII - CS - Lesson 9 - List and Tuple - Quiz 1

12th Grade

25 Qs

CSV File handling in Python

CSV File handling in Python

12th Grade

25 Qs

AP CSA | U2_L1 Variables

AP CSA | U2_L1 Variables

12th Grade

25 Qs

Algoritma dan Pemrograman

Algoritma dan Pemrograman

12th Grade - University

25 Qs

Python List and Nested List Assessment

Python List and Nested List Assessment

Assessment

Quiz

Computers

12th Grade

Hard

Created by

Dhanalakshmi Murali

Used 2+ times

FREE Resource

30 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

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

[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

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?