ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(float('1_000.5'), end=' ')
try:
    int('1__0')
except ValueError:
    print('VE')
  1. A. 1000.5 VE
  2. B. 1000.5 ValueError
  3. C. 1000 VE
  4. D. 1_000.5 VE

Correct answer: A. 1000.5 VE

Underscores are allowed between digits in float and int literal strings, but not two in a row. Here float('1_000.5') is 1000.5, and int('1__0') raises ValueError.

More Python Programming questions

Exams that ask this topic