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}')
  1. A. 4 1234 1236 -1234
  2. B. 4 1235 1236 -1235
  3. C. 5 1234 1236 -1234
  4. 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

Exams that ask this topic