ProgrammingHardCapgemini · Infosys pattern

What is printed?

What is printed?
print(all([1, 2, 3]), all([1, 0, 3]), any([0, 0, 0]), any([0, 1, 0]))
  1. A. True True False True
  2. B. True False False True
  3. C. True False True True
  4. D. False False False True

Correct answer: B. True False False True

all() is True only if every element is truthy: [1,2,3] all truthy (True); [1,0,3] has a 0 (False). any() is True if at least one is truthy: [0,0,0] all falsy (False); [0,1,0] has a 1 (True).

More Python Programming questions

Exams that ask this topic