ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(len(f'{1234.5:.0f}'), f'{1234.5:.0f}', f'{1235.5:.0f}', f'{-1234.5:.0f}')- A. 4 1234 1236 -1234
- B. 4 1235 1236 -1235
- C. 5 1234 1236 -1234
- D. 4 1234 1235 -1234
Correct answer: A. 4 1234 1236 -1234
Halves round to the even neighbour, so 1234.5 becomes 1234 and 1235.5 becomes 1236. The sign is kept for negative values, so -1234.5 gives -1234.
More Python Programming questions
- What is printed? python print(1e3 == 103, int(1e3) is not None, 1e3 // 1 == 103, type(1e3 // 1).name)
- What is printed? python print('%x' % -255, '%o' % 8, '%e' % 0.0, '%.0e' % 12345)
- What is printed? python print(5 & 6 | 1, 5 & (6 | 1), 5 ^ 6 & 1, 1 | 2 ^ 3 & 4)
- What is printed? python print(-1 >> 1, -1 << 2, -5 >> 10, 5 >> -0 if False else 0)
- What is printed? python print(bin(-1 & 0b111), (-1) & 0xF == 15, -16 >> 2, -15 >> 2)
- What is printed? python print(''.join(sorted(set('mississippi'))), ''.join(sorted('mississippi', key=lambda c: (-'mississippi'.count(c)…