ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(' '.join(str(x) for x in range(3, 0, -1)), ' '.join(map(str, [])) == '')- A. 1 2 3 True
- B. 3 2 1 None
- C. 3 2 1 True
- D. 3 2 1 False
Correct answer: C. 3 2 1 True
range(3, 0, -1) gives 3, 2, 1, and join gives the string '3 2 1'. join over an empty iterable returns the empty string, so the comparison is True.
More Python Programming questions
- What is printed? python def gensquares(n): for i in range(n): yield i i print(list(gensquares(4)), sum(gensquares(4)), max(gensquares(0)…
- What is printed? python x = 255 print(f'{x:x}', f'{x:08b}', f'{x:o}', f'{x:#06x}')
- What is printed? python print(3 in {1: 'a', 3: 'b'}, '3' in {1: 'a', 3: 'b'}, 3 in [1, 3], 3 in range(3, 4))
- What is printed? python print(list(zip('ab', 'cd', 'ef'))[1], dict(zip('ab', [1])))
- What is printed? python print(len('héllo'), len('héllo'.encode('utf-8')), 'é'.encode('utf-8'))
- What is printed? python import math print(math.floor(7 / 2) 2 + 7 % 2, 7 // 2 2 + 7 % 2)