ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(int(True) - ~True, 4 >> True, True << 3, True + True * True)
  1. A. 3 4 8 2
  2. B. 2 2 8 2
  3. C. 3 2 8 2
  4. D. 3 2 8 3

Correct answer: C. 3 2 8 2

True behaves as 1 in arithmetic and shifts, so ~True is -2 and the first value is 1 + 2 = 3. 4 >> 1 is 2, True << 3 is 8, and True + True * True is 2.

More Python Programming questions

Exams that ask this topic