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']))- A. 0 1 2 1,10 x z
- B. 0 1 2 01,10 z x
- C. 0 1 2 01,10 x z
- 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
- What is printed? python print(max(3, 3.0), max(3.0, 3), min(-0.0, 0), min(0, -0.0))
- What is printed? python print('abc'[1:][::-1], 'abc'[::-1][1:], 'abcdef'[::-2][:2])
- What is printed? python print(float('nan') != float('nan'), float('inf') == float('inf'), float('inf') - float('inf') == 0, -float('inf')…
- What is printed? python x = [1, 2, 3] y = x x = x + [4] print(y, x, y is x)
- What is printed? python print(int('٤٢'), '٤٢'.isnumeric(), ' 42n'.isdigit(), int('42n'))
- What is printed? python from collections import Counter c = Counter() c['a'] += 2 c.update('ab') print(c['a'], c['b'], c['z']…