Built-ins & Standard Library · Question 20 · Hard
all, any and max are each given an empty list, with a default supplied to max. What does this code print?
print(all([]), any([]), max([], default=0))
- False False 0
- True True 0
- False False None
- True False 0
Answer and explanation
Answer: D. True False 0
Explanation: all of an empty list is True because no item fails the test, while any is False because no item passes it. max of an empty list would raise ValueError, but the default argument makes it return 0.
Previous: A defaultdict(int) is updated for one key, read for a second key and tested…
Practise built-ins & standard library
Try a fresh set of built-ins & standard library questions with an explanation after every answer, free and without signing up: Built-ins & Standard Library practice. Or sit a full placement mock test.
More built-ins & standard library questions
- Booleans are used in an isinstance check, in addition and inside sum. What…
- A program imports the same module helper from two different files. How many…
- A defaultdict(int) is updated for one key, read for a second key and tested…
More python practice
Variables, Types & Operators · Python Strings · Lists & Tuples · Dictionaries & Sets · Conditions & Loops · Functions & Scope · Comprehensions & Generators · Classes & Objects
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge