ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(divmod(-9, 2), divmod(9, -2))
- A. (-5, 1) (-5, -1)
- B. (-4, -1) (-4, 1)
- C. (-4, 1) (-5, -1)
- D. (-5, 1) (-4, -1)
Correct answer: A. (-5, 1) (-5, -1)
-9 // 2 floors to -5 and the remainder is 1. 9 // -2 floors to -5 and the remainder takes the divisor's sign, giving -1.
More Python Programming questions
- What is printed? python x = [1, 2] x += x x = 2 print(x)
- What is printed? python d = dict(zip('abc', range(3))) print(d.popitem(), d)
- What is printed? python t = (3, 1, 2) print(sorted(t) == list(t), tuple(sorted(t)), t)
- What is printed? python print(max('apple', 'banana', key=len), max([], default=None))
- What is printed? python print([y for x in [1, 2, 3] if (y := x + 1) % 2 == 0])
- What is printed? python print(all(i < j for i, j in zip([1, 2, 3], [2, 3, 3])))