Tuples Flashcards

1
Q

True or False: Tuples can be reassigned

A

False - tuples are immutable (can index but not modify)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the most common use case for tuples in SWE interviews?

A

Key for hash map:

myMap = {(1, 2): 3}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly