ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(0x10 + 0o10 + 0b10, 1_0 + 0x_1, 1e1 + 1, 1j * 1j)
  1. A. 26 11 11.0 (-1+0j)
  2. B. 24 11 11.0 (-1+0j)
  3. C. 26 12 11.0 (-1+0j)
  4. D. 26 11 11 (-1+0j)

Correct answer: A. 26 11 11.0 (-1+0j)

Literals in hex, octal and binary give 16 + 8 + 2 = 26. Underscores are allowed in numeric literals, and 1e1 is a float, so the sum is 11.0. j * j is -1 as a complex number.

More Python Programming questions

Exams that ask this topic