ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print(int(' 3 ') + 1, int('3\n') * 2, float(' 2.5\t') * 2)
  1. A. 4 6 2.5
  2. B. 4 3 5.0
  3. C. 5 6 5.0
  4. D. 4 6 5.0

Correct answer: D. 4 6 5.0

int and float ignore surrounding whitespace, including newlines and tabs. Adding 1 to 3 gives 4, and doubling 3 gives 6. Doubling 2.5 gives 5.0.

More Python Programming questions

Exams that ask this topic