ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(list(range(10, 0, -4)), [sum(r) for r in [(1, 2), (3,)]])
- A. [10, 6, 2] [2, 3]
- B. [10, 6, 2] [3, 3]
- C. [10, 6, 2, 0] [3, 3]
- D. [10, 6] [3, 3]
Correct answer: B. [10, 6, 2] [3, 3]
range(10, 0, -4) gives 10, 6, 2 and stops before 0. Each row is summed, giving 3 and 3.
More Python Programming questions
- What is printed? python print(2 0.5 2 0.5, 2 0.5 2 0.5 == 2.0, round(2 0.5 2 0.5))
- What is printed? python print(min(map(str, [10, 9, 100])), sorted(['10', '9', '100']), sorted([10, 9, 100]))
- What is printed? python print(len([x for x in range(10) if x % 3 == 0]), sum(range(0, 10, 3)))
- 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)