ProgrammingHardCodeforces-style · placement coding round
What is printed?
What is printed?
print(max(range(7), key=lambda i: (i % 3, i)))
- A. 5
- B. 2
- C. 6
- D. 4
Correct answer: A. 5
The key pairs each value's remainder mod 3 with the value itself. The largest key is (2, 5), so 5 is the answer.
More Python Programming questions
- What is printed? python print(5 // 0.5, 5 % 0.5)
- What is printed? python print('xy'.replace('', '-'))
- What does this Python code print? a = [1, 2, 3] b = a a += [4] a = a + [5] print(b, a)
- What does this Python code print? it = iter([1, 2, 3, 4, 5]) print(any(x > 2 for x in it), next(it))
- What does this Python code print? def f(x, acc=[]): acc.append(x) return len(acc) print(f(1), f(2), f(3, []), f(4))
- What is the output of this Python code? t = ([1], 5) try: t[0] += [2] except TypeError: print("err", end=" ") print(t)