ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print('²'.isdigit(), '²'.isdecimal(), '٣'.isdecimal())
  1. A. True False True
  2. B. True True True
  3. C. False False True
  4. D. True False False

Correct answer: A. True False True

isdigit accepts superscript digits such as U+00B2, but isdecimal does not. Arabic-Indic digits are decimal, so they pass isdecimal. int() accepts only the decimal class, so int('²') would raise ValueError.

More Python Programming questions

Exams that ask this topic