Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Python Objects, Values, Types, and Identity Code

Practice reasoning about identity, mutation, equality, and hashability with small Python programs.

Core ~10 min read

Challenge 1

Make the program report whether alias refers to the same list object as items.

python Your answer
items = [1, 2]
alias = items

print()

Press Ctrl⌘Enter to check your answer

Challenge 2

Mutate the existing list by adding 3; do not create a replacement list.

python Your answer
items = [1, 2]


print(items)

Press Ctrl⌘Enter to check your answer

Challenge 3

Compare two separate lists by value rather than identity.

python Your answer
left = [1, 2]
right = [1, 2]

print()

Press Ctrl⌘Enter to check your answer

Challenge 4

Return the hash of a string so it can be inspected as a hashable value.

python Your answer
label = "Python"

print()

Press Ctrl⌘Enter to check your answer