ProgrammingVery hardTCS NQT · Accenture

What is printed?

What is printed?
print(int('٤٢'), '٤٢'.isnumeric(), ' 42\n'.isdigit(), int('42\n'))
  1. A. 42 True True 42
  2. B. 42 False False 42
  3. C. 42 True False 0
  4. D. 42 True False 42

Correct answer: D. 42 True False 42

int() accepts Arabic-Indic digits and ignores surrounding whitespace, including a trailing newline. isdigit() is False because the string has a space and newline around the digits.

More Python Programming questions

Exams that ask this topic