Skip to content
Foxipa
Code Completion 6 Challenges

Complete the Python tuples and sets code

Practice tuple construction and unpacking, set creation and operations, and immutable set values.

Beginner ~7 min read

Challenge 1

Create a one-item tuple.

python Your answer
language = 

Press Ctrl⌘Enter to check your answer

Challenge 2

Unpack the tuple into two names.

python Your answer
version = (3, 14)
major, minor = 

Press Ctrl⌘Enter to check your answer

Challenge 3

Create a set from an iterable.

python Your answer
letters = (["a", "b", "a"])

Press Ctrl⌘Enter to check your answer

Challenge 4

Keep only values present in both sets.

python Your answer
frontend = {"HTML", "CSS"}
backend = {"CSS", "Python"}
shared = frontend  backend

Press Ctrl⌘Enter to check your answer

Challenge 5

Keep values in the first set that are absent from the second.

python Your answer
frontend = {"HTML", "CSS"}
backend = {"CSS", "Python"}
only_frontend = frontend  backend

Press Ctrl⌘Enter to check your answer

Challenge 6

Create an immutable set from roles.

python Your answer
roles = ({"reader", "editor"})

Press Ctrl⌘Enter to check your answer