ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(len([x for x in range(10) if x % 3 == 0]), sum(range(0, 10, 3)))
- A. 4 18
- B. 3 18
- C. 4 15
- D. 3 9
Correct answer: A. 4 18
The multiples of 3 below 10 are 0, 3, 6 and 9, so there are four. Their sum is 18.
More Python Programming questions
- What is printed? python x = [3, 1, 2] y = sorted(x) x.sort(reverse=True) print(x, y, x is y)
- What is printed? python print(list(map(sum, zip([1, 2], [3, 4]))), list(zip([[1, 2], [3, 4]])))
- What is printed? python print(10 // 3 3 + 10 % 3 == 10, -10 // 3 3 + -10 % 3 == -10, 10 // -3 -3 + 10 % -3 == 10)
- What is printed? python print(0 == False, '' == False, [] == False, None == False)
- What is printed? python from collections import Counter print(Counter('hello').mostcommon(2))
- What is printed? python def keyfn(p): return (-p[1], p[0]) people = [('bo', 3), ('al', 5), ('cy', 3)] print([p[0] for p in sorted(people…