
Python Sets and Dictionaries Worksheet
Authored by Prethija Jafferson
Engineering
Professional Development
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a characteristic of sets in Python?
Ordered collection
Allows duplicates
Mutable and supports mathematical set operations
Supports indexing and slicing
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Why do sets in Python not support indexing?
They are mutable
They maintain order
They are unordered and use hash-based storage
They allow duplicates
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How can you create a set from the string 'spam'?
set = 'spam'
set('spam')
{'spam'}
list('spam')
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What happens when you try to add a duplicate element to a set?
It raises an error
The set remains unchanged
The duplicate replaces the existing one
The set becomes a list
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which elements can be added to a set?
Lists
Dictionaries
Tuples
Sets
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the union operation on sets do?
Finds common elements
Combines all unique elements
Finds elements in one but not the other
Checks if one is subset of another
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the difference between remove() and discard() in sets?
remove() does not raise error if element not present, discard() does
discard() does not raise error if element not present, remove() does
Both raise errors
No difference
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?