ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(divmod(-1, 10**20), divmod(10**20, -1))
- A. (-1, 99999999999999999998) (100000000000000000000, 0)
- B. (-1, 99999999999999999999) (-100000000000000000000, 0)
- C. (0, -1) (-100000000000000000000, 0)
- D. (-1, 100000000000000000000) (-100000000000000000000, 0)
Correct answer: B. (-1, 99999999999999999999) (-100000000000000000000, 0)
-1 = (-1) * 10**20 + (10**20 - 1), which gives quotient -1 and remainder 10**20 - 1. Dividing 10**20 by -1 gives the negative quotient with remainder 0.
More Python Programming questions
- What is printed? python print(int(1e20) == 1020, int(1e20 + 1) == 1020 + 1, int(1e20) - 1020)
- What is printed? python print(max(float('nan'), 1.0), min(float('nan'), 1.0), max(1.0, float('nan')))
- What is printed? python print(len(str(3100)), str(3100)[-1], str(3100)[:3])
- What is printed? python s = 'x' t = s s = s + 'y' print(t, s, t is s)
- What is printed? python print(''.join(map(chr, [72, 105])), ord('A') > 127, len('ab'.encode('utf-8')))
- What is printed? python print(list('hi'.encode('utf-16-le')), len('hi'.encode('utf-32')))