Tuples: What Does This Print
What does this print? · Intermediate · about 8 min
Read each short program and type exactly what it prints, with each printed line on its own line. If a program stops with an error, type the error's name, like TypeError.
Example
t = (4, 5, 6) print(t[1], len(t))
prints
5 3
Program 1
t = (5) u = (5,) print(type(t), type(u))
Program 2
t = (1, 2, 3) t[0] = 9 print(t)
Program 3
t = (1, [2, 3]) t[1].append(4) print(t)
Program 4
first, *rest = (10, 20, 30, 40) print(first, rest)
Program 5
a, b = 1, 2 a, b = b, a + b print(a, b)
Program 6
t = (3, 1, 2) print(sorted(t), t)
Program 7
x, y = (1, 2, 3) print(x)
Program 8
points = {(0, 0): "origin"} print(points[(0, 0)], (1, 2) < (1, 3))