ProgrammingModerateInfosys · Accenture · Capgemini pattern

What is printed?

What is printed?
print("%d items" % 3.9, int("0x1A", 16))
  1. A. 3 items ValueError
  2. B. 3.9 items 26
  3. C. 3 items 26
  4. D. 4 items 26

Correct answer: C. 3 items 26

%d converts the float 3.9 to an int by truncation, giving 3. int("0x1A", 16) accepts the 0x prefix when the base is 16, and 0x1A = 16 + 10 = 26.

More Python Programming questions

Exams that ask this topic