Calculating Minimum, Maximum, and Sum
The min
, max
, and sum
functions calculate the minimum value
, maximum value
, and total sum
for iterable objects such as lists and tuples.
min() Function
The min
function returns the smallest value within a list or tuple.
Example of min Function
numbers = [4, 2, 8, 6] min_element = min(numbers) print(min_element) # 2
max() Function
The max
function returns the largest value within a list or tuple.
Example of max Function
numbers = (4, 2, 8, 6) max_element = max(numbers) print(max_element) # 8
sum() Function
The sum
function returns the total sum of all numbers within a list or tuple.
Example of sum Function
numbers = [4, 2, 8, 6] sum_of_numbers = sum(numbers) print(sum_of_numbers) # 20
Mission
0 / 1
Which function is most suitable to fill in the blank?
The function that calculates the total of elements in a list is .
min
max
sum
len
Guidelines
AI Tutor
Publish
Design
Upload
Notes
Favorites
Help
Code Editor
Run
Generate
Execution Result