Recall & Review
beginner
What does the
max() function do in Python?The
max() function returns the largest item from an iterable or the largest of two or more arguments.Click to reveal answer
beginner
What does the
min() function do in Python?The
min() function returns the smallest item from an iterable or the smallest of two or more arguments.Click to reveal answer
beginner
How can you find the maximum number in a list
[3, 7, 2, 9]?Use
max([3, 7, 2, 9]) which will return 9.Click to reveal answer
beginner
How can you find the minimum value among numbers 5, 10, and 1?
Use
min(5, 10, 1) which will return 1.Click to reveal answer
intermediate
Can
max() and min() be used with strings? How?Yes! They compare strings alphabetically (based on Unicode). For example,
max(['apple', 'banana', 'cherry']) returns 'cherry' because 'c' comes after 'a' and 'b'.Click to reveal answer
What will
max([4, 9, 1, 7]) return?✗ Incorrect
max() returns the largest number, which is 9.What does
min('dog', 'cat', 'bat') return?✗ Incorrect
Strings are compared alphabetically. 'bat' comes before 'cat' and 'dog'.
Which of these is a valid way to use
max()?✗ Incorrect
All options are valid uses of
max().What will
min([]) do?✗ Incorrect
min() raises a ValueError if given an empty iterable.How does
max() decide which item is largest when given strings?✗ Incorrect
max() compares strings alphabetically using Unicode order.Explain how to use
max() and min() with a list of numbers.Think about finding the highest and lowest scores in a game.
You got /4 concepts.
Describe what happens if you use
max() or min() on strings.Think about dictionary order.
You got /4 concepts.