ProgrammingHardGATE CS · Product-company placement

What is printed?

What is printed?
t = 1, 2,
u = (3)
v = ()
w = (4,) * 0
print(type(t).__name__, len(t), type(u).__name__, v == w, (1, 2) < (1, 2, -1))
  1. A. tuple 2 int True True
  2. B. tuple 3 tuple True True
  3. C. tuple 2 int False True
  4. D. tuple 2 int True False

Correct answer: A. tuple 2 int True True

The comma makes the tuple, so `1, 2,` is a 2-tuple, while (3) is just the int 3. Every empty tuple is equal. A tuple that is a proper prefix of another is smaller.

More Python Programming questions

Exams that ask this topic