ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(int('  -0012  '), int('+5'), float('-.5'), float('5.'))
  1. A. -12 5 -0.5 5
  2. B. 0 5 -0.5 5.0
  3. C. -12 +5 -.5 5.
  4. D. -12 5 -0.5 5.0

Correct answer: D. -12 5 -0.5 5.0

int accepts surrounding whitespace and a sign, and leading zeros are fine in base 10. float accepts '-.5' and '5.' as valid numeric strings, and both give floats.

More Python Programming questions

Exams that ask this topic