ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print(10 // 3, 10 % 3, divmod(10, 3), (10 // 3) * 3 + 10 % 3)
- A. 3 1 (3, 1) 9
- B. 3 1 (3, 1) 10
- C. 3 2 (3, 2) 10
- D. 3 1 (3, 1) 11
Correct answer: B. 3 1 (3, 1) 10
10 // 3 is 3 and 10 % 3 is 1, and divmod returns both as a pair. Recombining them gives back 10.
More Python Programming questions
- What is printed? python print([1, 2, 3].index(2), 'abc'.index('bc'), (1, 2).index(2), [1, 2, 3].count(4))
- What is printed? python print(float('-0') == 0, str(float('-0')), str(0 -1.0), 0.0 -1)
- What is printed? python print(1 < 2 < 3 < 4 == 4.0, 4 == 4.0 != 5, 1 < 3 > 2 < 2)
- What is printed? python print(oct(0o17 + 0b11), 0x10 | 0o7, 10 + 0x1)
- What is printed? python print('x'.center(4, '-') + '|', '7'.zfill(3) + '|', '-7'.zfill(4))
- What is printed? python print(max(3, 3.5, 2), min('b', 'a', 'c'), max([1, 2], [1, 3]))