ProgrammingVery hardTCS NQT · Accenture

What is printed?

What is printed?
print('ab' in ['a', 'ab'], 'ab' in 'a,ab'.split(','), 'a' in 'abc' and 'ac' in 'abc')
  1. A. True True False
  2. B. True False False
  3. C. False True False
  4. D. True True True

Correct answer: A. True True False

'in' on a list checks whole elements, and 'ab' is one. 'in' on a string checks substrings, and 'ac' is not a substring of 'abc', so the and-expression is False.

More Python Programming questions

Exams that ask this topic