ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print(' '.join(str(i) for i in range(3)), ','.join(f'{i:02d}' for i in (1, 10)), '|'.join(['x']), ''.join(['', 'z']))
  1. A. 0 1 2 1,10 x z
  2. B. 0 1 2 01,10 z x
  3. C. 0 1 2 01,10 x z
  4. D. 0 1 2 01,10 x y

Correct answer: C. 0 1 2 01,10 x z

The first join puts spaces between 0, 1 and 2. The format spec 02d zero-pads each number, giving 01 and 10, and a single-element join returns the element unchanged.

More Python Programming questions

Exams that ask this topic