
Mastering Python Data Structures
Quiz
•
Computers
•
University
•
Practice Problem
•
Hard
Solaf Ali
FREE Resource
Enhance your content in a minute
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What method would you use to add an element to a list in Python?
Use the 'extend()' method.
Use the 'add()' method.
Use the 'insert()' method.
Use the 'append()' method.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Explain how to create a dictionary comprehension to generate a dictionary of squares from a list of numbers.
{x: x**2 for x in numbers}
{x: x^2 for x in numbers}
{x: x*2 for x in numbers}
{x: x+1 for x in numbers}
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you slice an array to get the first three elements?
array.slice(3)
array.slice(0, 3)
array.slice(1, 4)
array.slice(0, 2)
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the difference between mutable and immutable types in Python?
Mutable types cannot be changed; immutable types can be changed after creation.
Both mutable and immutable types can be changed at any time.
Mutable types are faster than immutable types in all cases.
Mutable types can be changed; immutable types cannot be changed after creation.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How can you remove an item from a list by its value?
Use del list[value] to delete an item by its value.
Use list.pop(index) to remove an item by its index.
Use list.clear(value) to remove all items from the list.
Use list.remove(value) to remove an item by its value.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Write a dictionary comprehension that creates a dictionary from two lists: keys and values.
{key: values[key] for key in range(len(keys))}
{key: value for key in keys}
{key: value for key, value in zip(keys, values)}
{key: values[key] for key in keys}
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code: arr = [1, 2, 3, 4]; print(arr[1:3])?
[2, 3]
[1, 2]
[1, 2, 3, 4]
[3, 4]
Access all questions and much more by creating a free account
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
10 questions
Website Usability and UX
Quiz
•
University
15 questions
DAWN CIE
Quiz
•
University
11 questions
Final Keamanan Komputer / Sistem Keamanan Jaringan
Quiz
•
University
10 questions
Hands-on Modul 3
Quiz
•
University
10 questions
Visual Basic 2010
Quiz
•
8th Grade - University
10 questions
CS100||MsWord
Quiz
•
University
13 questions
Functional Programming
Quiz
•
University
11 questions
Trees
Quiz
•
University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
