ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(int(2.675 * 100), round(2.675, 2))
  1. A. 267 2.68
  2. B. 268 2.67
  3. C. 267 2.67
  4. D. 268 2.68

Correct answer: C. 267 2.67

2.675 is stored as about 2.67499999999999982, so 2.675 * 100 is 267.49999999999997 and int truncates to 267. round uses the exact stored value, which is below the midpoint, so it gives 2.67.

More Python Programming questions

Exams that ask this topic