ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(list(map(len, ['', 'ab', 'abc'])), sum(map(len, ['', 'ab', 'abc'])))
- A. [0, 2, 3] 3
- B. [0, 2, 3] 5
- C. [0, 2, 3] 6
- D. [1, 2, 3] 5
Correct answer: B. [0, 2, 3] 5
len of each string gives 0, 2 and 3. Their sum is 5, and the empty string contributes nothing.
More Python Programming questions
- What is printed? python print(10 in range(0, 20, 5), 11 in range(0, 20, 5))
- What is printed? python print(sum(range(1, 101)) 2 - sum(i i for i in range(1, 101)))
- What is printed? python print(len(str(264)), sum(map(int, str(264))))
- What is printed? python print(all(int(c) % 2 == 0 for c in '24680'), any(c in 'aeiou' for c in 'rhythm'))
- What is printed? python print(''.join(c.upper() if i % 2 else c for i, c in enumerate('python')))
- What is printed? python print(' '.join(w[::-1] for w in 'hello big world'.split()))