W3Tutorials.net
Toggle Menu
Home
Online Go Compiler
Tutorials
Javascript Tutorials
Python Tutorials
Go Tutorials
Blog
All Posts
Python Data Structures
Assess your knowledge of lists,tuples,dictionaries,and sets.
1. Which Python data structure uses curly braces and stores key-value pairs?
List
Tuple
Dictionary
Set
2. Select all immutable data structures in Python.
List
Tuple
String
Set
3. Sets allow duplicate elements.
True
False
4. What is the built-in function to get the number of elements in a list?
5. Which method is used to remove and return the last element of a list?
pop()
remove()
delete()
discard()
6. Which of the following are valid ways to create an empty list?
[]
list()
()
{}
7. What data structure is defined with square brackets `[]` and is mutable?
Tuple
Set
List
String
8. Dictionaries in Python 3.7+ preserve the insertion order of keys.
True
False
9. What data structure is used to store unique elements and is denoted by curly braces `{}`?
10. Which list methods modify the original list in-place (do not return a new list)?
append()
extend()
sorted()
reverse()
11. Which operator checks if a key exists in a dictionary?
in
exists
has_key
contains
12. A tuple can be converted to a list using the `list()` function.
True
False
13. What method adds multiple elements to a set at once?
14. Which of the following are valid string methods in Python?
append()
replace()
split()
pop()
15. What is the output of `len((1, 2, 3, (4, 5)))`?
4
5
2
Error
Reset
Answered 0 of 0 — 0 correct