
Python_Quiz4_List

Quiz
•
Computers
•
University
•
Hard

Rubin Ray
Used 5+ times
FREE Resource
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following list comprehension? my_list = [x**2 for x in range(5)] print(my_list)
[0, 1, 2, 3, 4]
[1, 2, 3, 4, 5]
[0, 1, 4, 9, 16]
[1, 4, 9, 16, 25]
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code?
my_list1 = [1, 2, 3]
my_list2 = my_list1.copy()
my_list2.append(4)
print(my_list1)
[1, 2, 3, 4]
[1, 2, 3]
[4]
None
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which method is used to remove all elements from a list?
clear()
delete()
remove()
pop()
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you access the element at the second position of the first sublist in a nested list 'my_list'?
my_list[0][1]
my_list[1][0]
my_list[0][2]
my_list[1][1]
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code? my_list = [[1, 2], [3, 4], [5, 6]] flat_list = [item for sublist in my_list for item in sublist] print(flat_list)
[[1, 2], [3, 4], [5, 6]]
[1, 2, 3, 4, 5, 6]
[1, 3, 5, 2, 4, 6]
[2, 4, 6]
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How can you create a new list containing only the unique elements from an existing list 'my_list'?
new_list = list(set(my_list))
new_list = my_list.unique()
new_list = my_list.distinct()
new_list = my_list.remove_duplicates()
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the output of the following code? my_list = [1, 2, 3, 4, 5] my_list *= 2 print(my_list)
[1, 2, 3, 4, 5]
[2, 4, 6, 8, 10]
[1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
[5, 4, 3, 2, 1, 5, 4, 3, 2, 1]
Create a free account and access millions of resources
Similar Resources on Wayground
16 questions
COMP177 Mod 8 - Lists & Dictionaries

Quiz
•
University
20 questions
Python Lists

Quiz
•
University
20 questions
Python Programming

Quiz
•
University
16 questions
Quiz on List and Tuples

Quiz
•
University
20 questions
Data Analysis using Python

Quiz
•
University
15 questions
ROTC Make-up Quiz

Quiz
•
University
20 questions
UTS - Struktur Data

Quiz
•
University
18 questions
Linked List

Quiz
•
KG - University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
10 questions
UPDATED FOREST Kindness 9-22

Lesson
•
9th - 12th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
20 questions
US Constitution Quiz

Quiz
•
11th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Would you rather...

Quiz
•
KG - University
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
10 questions
The Constitution, the Articles, and Federalism Crash Course US History

Interactive video
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
16 questions
Water Modeling Activity

Lesson
•
11th Grade - University
10 questions
ACT English prep

Quiz
•
9th Grade - University