Tuples Flashcards
1
Q
True or False: Tuples can be reassigned
A
False - tuples are immutable (can index but not modify)
2
Q
What is the most common use case for tuples in SWE interviews?
A
Key for hash map:
myMap = {(1, 2): 3}
3
Q
Why is using a tuple better than using a list as a key in a hash map?
A
Lists can’t be keys in Python. Tuples are a great way to get around this