ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(divmod(10, 3)[::-1], divmod(-10, 3)[::-1], divmod(10, -3)[::-1])
- A. (1, 3) (2, -4) (-2, -4)
- B. (1, 3) (-4, 2) (-4, -2)
- C. (3, 1) (2, -4) (-2, -4)
- D. (1, 3) (2, -4) (-4, -2)
Correct answer: A. (1, 3) (2, -4) (-2, -4)
divmod(-10, 3) is (-4, 2), and reversing it gives (2, -4). divmod(10, -3) is (-4, -2), so reversed it is (-2, -4).
More Python Programming questions
- What is printed? python print(-5 % 3 == 1, 5 % -3 == -1, -5 // -3, 5 // -3)
- What is printed? python s = 'a-bc d' print(s.replace('-', ' ').replace('', ' ').split(), s.translate({45: None}))
- What is printed? python print('abc'.index('c') + 'abc'.rindex('a'), 'aXbXc'.rsplit('X', 1), 'a b'.title())
- What is printed? python import string print(string.asciilowercase.index('z'), string.digits[::-1][:3], string.asciiuppercase[25] +…
- What is printed? python print(int('1' 30) % 97, pow(10, 30, 97), (1030 - 1) // 9 % 97)
- What is printed? python print(sum(int(c) for c in str(21000)), len(str(21000)))