ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(list(map(lambda x, y: x * y, [1, 2, 3], [4, 5])))
- A. [4, 10, 0]
- B. [4, 10, 3]
- C. [4, 5, 10]
- D. [4, 10]
Correct answer: D. [4, 10]
map with several iterables stops at the shortest one, just as zip does. The pairs are (1, 4) and (2, 5), so the result has two items.
More Python Programming questions
- What is printed? python print(sum([[1], [2, 3]], []), sum([[1], [2]], [0]) if False else 'skip')
- What is printed? python print(''.join(sorted(set('hello'), key=ord)))
- What is printed? python print(len({0.0, -0.0, 1}), hash(1) == hash(1.0) == hash(True))
- What is printed? python print(1 == 1.0 == True, {1: 'a'}.get(True))
- What is printed? python print([i j for i, j in zip(range(3), range(3, 0, -1))])
- What is printed? python print(''.join(chr(ord('a') + (ord(c) - ord('a') + 3) % 26) for c in 'xyz'))