
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
SOAL : Pengenalan Basis Data
Quiz
•
University
10 questions
Quiz Network Cabling Structure - SSK20353 - Network Technology
Quiz
•
University
15 questions
Dictionary Python
Quiz
•
University
15 questions
DIGITAL MARKETING
Quiz
•
University
10 questions
Scratch
Quiz
•
KG - Professional Dev...
9 questions
CBD2234 Week 2
Quiz
•
12th Grade - University
12 questions
Quiz No. 2.2 Hash Tables
Quiz
•
University
10 questions
LINUX MODULE 03 QUIZ
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
