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 == '')
- A. 2 3 True 20 True
- B. 2 2 True 10 True
- C. 2 2 True 20 True
- 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
- What is printed? python class Meta(type): def new(m, name, bases, d): d['tag'] = name.lower() return super().new(m, name, bases, d) class…
- What is printed? python print(type(10 / 5))
- Which of these built-in Python types is immutable?
- What is printed? python s = "placement" print(s[2:5])
- What is printed? python print(len({1, 2, 2, 3, 3, 3}))
- Which keyword turns an ordinary Python function into a generator function?