Python List and Nested List Assessment

Python List and Nested List Assessment

12th Grade

30 Qs

quiz-placeholder

Similar activities

Test IP

Test IP

12th Grade

25 Qs

TLJ (Materi Mikrotik Dasar)KKM70

TLJ (Materi Mikrotik Dasar)KKM70

12th Grade - University

26 Qs

Ôn Tập Học Kì I Lớp 4

Ôn Tập Học Kì I Lớp 4

4th Grade - University

35 Qs

ÔN TẬP TIN 7 HỌC KỲ 1

ÔN TẬP TIN 7 HỌC KỲ 1

1st - 12th Grade

25 Qs

Macromedia Flash

Macromedia Flash

8th Grade - Professional Development

26 Qs

UH-3 DASAR DESAIN GRAFIS

UH-3 DASAR DESAIN GRAFIS

1st Grade - University

25 Qs

PAS Informatika Semester Ganjil (1)

PAS Informatika Semester Ganjil (1)

9th - 12th Grade

25 Qs

Python List and Nested List Assessment

Python List and Nested List Assessment

Assessment

Quiz

Computers

12th Grade

Practice Problem

Hard

Created by

Dhanalakshmi Murali

Used 2+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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"]

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?