ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(7 // 0.5, 7 % 0.5, -7 // 0.5)
- A. 14 0.0 -14
- B. 14.0 0.0 -14.0
- C. 14.0 1.0 -14.0
- D. 14.0 0.0 -15.0
Correct answer: B. 14.0 0.0 -14.0
0.5 is exact in binary, so 7 / 0.5 is exactly 14 and the remainder is 0.0. Floor division with a float operand returns a float, and -7 // 0.5 is -14.0.
More Python Programming questions
- What is printed? python print(0.5 1074 == 0, 5e-324 > 0, 5e-324 / 2 == 0)
- What is printed? python print('abcabc'.replace('abc', 'x', 1), 'aaaa'.replace('aa', 'b'), 'aaa'.replace('', '-'))
- What is printed? python print('Mississippi'.lower().count('s'), 'Mississippi'.find('ss'), 'Mississippi'.rfind('ss'))
- What is printed? python print(float('-0') == 0.0, str(float('-0')), str(float('+0')))
- What is printed? python print(sum(1 for i in range(1, 1001) if '7' in str(i)))
- What is printed? python print(int(str(12345)[::-1]) - 12345, 12345 - int(str(12345)[::-1]))