ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
print(list(map(int, '1 2 3'.split()))[::-1])
- A. [1, 2, 3]
- B. [3, 2]
- C. [3, 2, 1]
- D. ['3', '2', '0']
Correct answer: C. [3, 2, 1]
split gives the strings 1, 2 and 3, map converts them to ints, and the reversed slice gives 3, 2, 1.
More Python Programming questions
- What is printed? python print(f'{7:03d}|{-7:d}|')
- What is printed? python x = 7 print(f'{x=}', f'{x 2 = }', f'{"a"!r:>4}')
- What is printed? python import keyword print(keyword.iskeyword('match'), keyword.issoftkeyword('match'), keyword.iskeyword('None')…
- What is printed? python print({'a': 1} | {'a': 2, 'b': 3}, {'a': 1} | {}, dict(a=1) == {'a': 1})
- What is printed? python print(format(1234567.891, ',.2f'), format(0.000123, 'e'), format(12, '>5'), format(3, '03'))
- What is printed? python print((1 + 2j) (3 - 1j), abs(3 + 4j), (1 + 2j).conjugate())