ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print(len('ab' + 'c' * 0), 'ab'[1:][0] * 2, ('ab' * 2)[::3])- A. 2 aa ab
- B. 2 bb a
- C. 2 bb ab
- D. 3 bb ab
Correct answer: C. 2 bb ab
'c' * 0 adds nothing, so the length is 2. 'ab'[1:] is b, which repeated gives bb. In abab, stepping by three takes indices 0 and 3, giving ab.
More Python Programming questions
- What is printed? python print(int(' 3 ') + 1, int('3n') 2, float(' 2.5t') 2)
- What is printed? python print(len('é'.encode('utf-8').decode('latin-1')), 'é'.encode('utf-8').decode('latin-1'))
- What is printed? python print(sum(1 for c in 'Mississippi' if c in 'aeiouAEIOU'), 'Mississippi'.lower().count('s')…
- What is printed? python print([] == [] or 1 / 0, [] and 1 / 0, 0 or 1 and 2)
- What is printed? python print(3 % 2 == 1 and 4 % 2 == 0, 3 // 2 == 1 or 1 / 0)
- What is printed? python print(f'{"":>3}|', f'{"x":^3}|', f'{None!s:>6}|')