0
0
Pythonprogramming~20 mins

max() and min() in Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
๐ŸŽ–๏ธ
MaxMin Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
โ“ Predict Output
intermediate
2: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))
A3
B7
C4
D9
Attempts:
2 left
๐Ÿ’ก Hint
max() returns the largest item in a list.
โ“ Predict Output
intermediate
2:00remaining
Minimum value with strings
What is the output of this code?
Python
words = ['apple', 'banana', 'cherry']
print(min(words))
Abanana
Bcherry
Capple
DError
Attempts:
2 left
๐Ÿ’ก Hint
min() compares strings alphabetically.
โ“ Predict Output
advanced
2:00remaining
max() with key argument
What is the output of this code?
Python
words = ['apple', 'banana', 'cherry']
print(max(words, key=len))
Abanana
Bcherry
Capple
DError
Attempts:
2 left
๐Ÿ’ก Hint
key=len tells max() to compare by length of words.
โ“ Predict Output
advanced
2:00remaining
min() with mixed types error
What error does this code raise?
Python
values = [3, '7', 2]
print(min(values))
AIndexError
BTypeError
CNo error, output is 2
DValueError
Attempts:
2 left
๐Ÿ’ก Hint
min() cannot compare numbers and strings directly.
๐Ÿง  Conceptual
expert
2: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))
ACharlie
BError
C95
DBob
Attempts:
2 left
๐Ÿ’ก Hint
max() on a dictionary returns the largest key by default.