ProgrammingModerateTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
t = (1)
u = (1,)
print(type(t).__name__, type(u).__name__, len(u))
  1. A. tuple int 0
  2. B. int tuple 1
  3. C. tuple tuple 1
  4. D. int int 1

Correct answer: B. int tuple 1

Parentheses alone do not make a tuple. A comma does, so t is the int 1, while u is a one-element tuple.

More Python Programming questions

Exams that ask this topic