ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
x = (5)
y = (5,)
print(type(x).__name__, type(y).__name__, len(y), ((5),) == (5,))
  1. A. tuple tuple 1 True
  2. B. int tuple 2 False
  3. C. int tuple 1 True
  4. D. int int 1 True

Correct answer: C. int tuple 1 True

Parentheses alone do not make a tuple; the comma does. (5) is the int 5, while (5,) is a one-item tuple, and ((5),) equals (5,).

More Python Programming questions

Exams that ask this topic