ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print(divmod(7, 2.5), divmod(-7.5, 2))
- A. (2.0, 2.0) (-3.0, 0.5)
- B. (2.0, 2.0) (-4.0, 0.5)
- C. (2.0, 0.5) (-4.0, 0.5)
- D. (3.0, 0.5) (-4.0, 0.5)
Correct answer: B. (2.0, 2.0) (-4.0, 0.5)
7 divided by 2.5 is 2.8, so the floor is 2 and the remainder is 2.0. For -7.5 divided by 2 the quotient floors to -4.0, leaving a remainder of 0.5.
More Python Programming questions
- What is printed? python print(0.1 + 0.1 + 0.1 == 0.3, 0.1 + 0.1 + 0.1, 0.3 == 3 0.1)
- What is printed? python print(bin(5 ^ 3), bin(-5 & 0b1111), int('-0b101', 2))
- What is printed? python print(2 -1, 2 -1074 > 0, 10 -3 == 0.001, 10 -2)
- What is printed? python print(' '.join(['a', '', 'b']), ' '.join([]) == '', '-'.join('abc'), 'x'.join(['1', '2', '3']))
- What is printed? python from functools import reduce print(reduce(lambda a, b: a + b, ['x', 'y', 'z'], ''), reduce(lambda a, b: a b…
- What is printed? python print(0.1 + 0.2 > 0.3, 0.3 - 0.1 == 0.2, 0.2 + 0.2 == 0.4, 0.4 - 0.2 == 0.2)