ProgrammingVery hardInfosys · Python · Advanced

What is printed?

What is printed?
print(True + True, sum([True, False, True]), isinstance(True, int), [10, 20, 30][True], 'ab' * False == '')
  1. A. 2 3 True 20 True
  2. B. 2 2 True 10 True
  3. C. 2 2 True 20 True
  4. D. 2 2 True 20 False

Correct answer: C. 2 2 True 20 True

bool is a subclass of int: True + True = 2, sum counts 2 Trues, True indexes position 1 (20), and 'ab' * 0 is ''.

More Python Programming questions

Exams that ask this topic