Last Updated: January 3, 2026
28 quizzes
Complete the code to create a set of unique user IDs from the given list of IDs
unique_user_ids = (user_id_list)Click an option to fill the blank:
Complete the code to check if a product code already exists in the inventory set
is_existing = 'P100' inventory_codesClick an option to fill the blank:
Complete the code to get all unique tags used across two blog posts
all_tags = tags_post1 tags_post2Click an option to fill the blank:
Which statement correctly creates an empty set of email addresses?
You have a set of usernames. Which property of sets is most useful to avoid duplicate registrations?
Which method would you use to add several new permissions from a list to an existing permissions set?
Which operation returns items that are in set_a but not in set_b?
You want to safely remove a user ID from a set without raising an error if it is missing. Which method should you use?
Which choice correctly describes a frozenset?
Which operation is valid on both set and frozenset objects?
You have two sets of attendees: morning_session and afternoon_session. Which operation gives attendees who joined both sessions?
What is the main benefit of using a frozenset as a dictionary key?
Which expression converts a string of tags into a set of unique characters?
Order the steps to collect unique error codes from a list and then check if a specific code is present.
Drag and drop to reorder, or use the arrows.
Order the steps to use a frozenset of allowed roles as a dictionary key for caching permissions.
Drag and drop to reorder, or use the arrows.
What is the output of this code?
1tags = {'python', 'backend', 'api'}
2print('python' in tags)What is the output of this code?
1a = {1, 2, 3}
2b = {3, 4}
3print(a & b)What is the output of this code?
1emails = {'a@example.com', 'b@example.com'}
2emails.add('a@example.com')
3print(len(emails))What is the output of this code?
1numbers = {1, 2, 3, 4}
2removed = numbers.discard(5)
3print(numbers)What is the output of this code?
1features = frozenset(['login', 'signup', 'profile'])
2print('login' in features)This function is supposed to remove a user from a set of active_users without raising an error if the user is not present. Find the bug.
Click on the line(s) that contain the bug.
def deactivate_user(active_users, user_id): if user_id not in active_users: active_users.remove(user_id) return active_usersThis code tries to use a set of tags as a dictionary key for caching results. Find the bug.
Click on the line(s) that contain the bug.
def cache_result(cache, tags, result): key = set(tags) cache[key] = result return cacheMatch each set method/operator with what it does in a notification system.
Click an item on the left, then click its match on the right. Click a matched item to unmatch.
Match each type with its correct description related to sets.
Click an item on the left, then click its match on the right. Click a matched item to unmatch.
Complete the code to build a set of unique visitors from a list, then freeze it for use as a dictionary key.
def freeze_unique_visitors(visitor_list): unique_visitors = (visitor_list) frozen_visitors = (unique_visitors) return frozen_visitorsClick an option to fill blank 1:
Complete the code to add multiple new skills to a developer_skills set, then remove an obsolete skill safely.
def update_skills(developer_skills, new_skills): developer_skills.(new_skills) developer_skills.('flash') return developer_skillsClick an option to fill blank 1:
Click the line that attempts to modify an immutable frozenset of roles.
Click on the line to select.
roles = frozenset(['admin', 'editor'])roles_set = {'viewer'}roles_set.add('guest')roles.add('guest')Click the line where a set is incorrectly used as a dictionary key.
Click on the line to select.
favorite_colors = {'red', 'blue'}color_ratings = {}color_ratings[favorite_colors] = 5print(color_ratings)