ProgrammingModerateProduct-company MCQ pattern
What is printed?
What is printed?
print(-7 // 2, -7 % 2)
- A. -4 1
- B. -3 -1
- C. -3 1
- D. -4 -1
Correct answer: A. -4 1
// floors toward minus infinity: -7/2 = -3.5 floors to -4. The remainder follows a = (a // b) * b + a % b, so -7 % 2 = -7 - (-8) = 1 and takes the sign of the divisor. C would give -3 and -1.
More Python Programming questions
- What is printed? python a = [1, 2, 3] b = a b += [4] print(a)
- What is printed? python print(bool("False"), bool(""), bool(0.0))
- What is printed? python nums = [3, 1, 2] print(nums.sort())
- What is printed? python print([x x for x in range(5) if x % 2])
- What is printed? python s = "hello" print(s[::-2])
- What is printed? python t = (1,) print(type(t).name, type((1)).name)