ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
print('ab' in ['ab', 'cd'], 'ab' in 'cdab', [] in [[]])- A. True False True
- B. True True True
- C. False True True
- D. True True False
Correct answer: B. True True True
in on a list checks equality with each item, and in on a string checks for a substring. [] equals the empty list inside [[]].
More Python Programming questions
- What is printed? python x = [1, 2, 3] del x[::2] print(x)
- What is printed? python print(max(map(len, ['aa', 'b', 'ccc'])))
- What is printed? python print(bool(range(0)), bool(range(1)), bool({0: 0}))
- What is printed? python print(sorted([True, 0, 2, False]))
- What is printed? python print(7 // 2 2, 7 / 2 2, 2 3 2)
- What is printed? python print([1, 2] < [1, 3], [1, 2] < [1], 'b' > 'abc')