ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print(2 ** 10 == 1024, 2 ** 10 == 1 << 10, 10 ** 2 ** 3, (10 ** 2) ** 3)
  1. A. True False 100000000 1000000
  2. B. True True 1000000 1000000
  3. C. True True 100000000 1000000
  4. D. True True 100000000 100000

Correct answer: C. True True 100000000 1000000

** is right-associative, so 10 ** 2 ** 3 is 10 ** 8. Parentheses force (10 ** 2) ** 3, which is 10 ** 6.

More Python Programming questions

Exams that ask this topic