ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print('abc' < 'abd' and 'x' or 'y', [] or 'empty', 0 or 0.0 or 'z')
  1. A. y empty z
  2. B. x empty z
  3. C. x [] z
  4. D. x empty 0

Correct answer: B. x empty z

'abc' < 'abd' is True, so and returns 'x', which is truthy, so or does not evaluate 'y'. An empty list is falsy, so the or returns 'empty', and 0 or 0.0 or 'z' returns z.

More Python Programming questions

Exams that ask this topic