Tuples Practice
Here are some tuples problems! What would Python output at each of the numbered questions below?
>>> a = (1, 2, 3)
>>> b = (3, 2, a)
>>> a #1
>>> b #2
>>> b[0] == a[2] #3
>>> c = (1, 2, 3)
>>> a == c #4
>>> a is c #5
>>> b[2] is c #6
>>> b[2] is a #7
>>> b[:2] #8
>>> c[1:] #9
>>> d = (a, b, c)
>>> d[1:2] #10
>>> d[2][2] #11
>>> d[1][0] #12
- (1, 2, 3)
- (3, 2, (1, 2, 3))
- True
- True
- False
- False
- True
- (3, 2)
- (2, 3)
- ((3, 2, (1, 2, 3)),)
- 3
- 3
I don't claim to be perfect so if you find an error on this page, please send me an email preferably with a link to this page so that I know what I need to fix!