ProgrammingVery hardProduct-company MCQ pattern

Which line is printed?

Which line is printed?
print(divmod(2**70, 10**6)[1] == 2**70 % 10**6, divmod(-2**70, 10**6)[1] == (-2**70) % 10**6, (-2**70) // 10**6 == -(2**70 // 10**6) - 1)
  1. A. True True False
  2. B. True True True
  3. C. False True True
  4. D. True False True

Correct answer: B. True True True

divmod and the % operator agree on the remainder, and floor division of a negative value is one less than the negated quotient unless the division is exact. 2**70 is not divisible by 10**6, so the last test holds.

More Python Programming questions

Exams that ask this topic