Challenge - 5 Problems
MaxMin Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
โ Predict Output
intermediate2:00remaining
Find the maximum value in a list
What is the output of this code?
Python
numbers = [3, 7, 2, 9, 4] print(max(numbers))
Attempts:
2 left
๐ก Hint
max() returns the largest item in a list.
โ Incorrect
The max() function finds the biggest number in the list. Here, 9 is the largest.
โ Predict Output
intermediate2:00remaining
Minimum value with strings
What is the output of this code?
Python
words = ['apple', 'banana', 'cherry'] print(min(words))
Attempts:
2 left
๐ก Hint
min() compares strings alphabetically.
โ Incorrect
min() returns the smallest string alphabetically. 'apple' comes before 'banana' and 'cherry'.
โ Predict Output
advanced2:00remaining
max() with key argument
What is the output of this code?
Python
words = ['apple', 'banana', 'cherry'] print(max(words, key=len))
Attempts:
2 left
๐ก Hint
key=len tells max() to compare by length of words.
โ Incorrect
max() with key=len returns the longest word. 'banana' and 'cherry' both have 6 letters, but 'banana' comes before 'cherry' alphabetically, so max() returns the first max length word it finds, which is 'banana'.
โ Predict Output
advanced2:00remaining
min() with mixed types error
What error does this code raise?
Python
values = [3, '7', 2] print(min(values))
Attempts:
2 left
๐ก Hint
min() cannot compare numbers and strings directly.
โ Incorrect
Python cannot compare int and str types with < or >, so it raises TypeError.
๐ง Conceptual
expert2:00remaining
max() and min() with dictionaries
Given this dictionary, what is the output of print(max(scores))?
Python
scores = {'Alice': 88, 'Bob': 95, 'Charlie': 90}
print(max(scores))Attempts:
2 left
๐ก Hint
max() on a dictionary returns the largest key by default.
โ Incorrect
max() returns the largest key alphabetically. 'Charlie' > 'Bob' > 'Alice'.