Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Python aggregation code

Practice all(), any(), min(), max(), and sum().

Beginner ~6 min read

Challenge 1

Return True when every number is positive.

python Your answer
numbers = [3, 8, 12]
result = 
print(result)

Press Ctrl⌘Enter to check your answer

Challenge 2

Check whether at least one number is negative.

python Your answer
numbers = [4, 7, -2, 9]
result = 
print(result)

Press Ctrl⌘Enter to check your answer

Challenge 3

Return the shortest word from the list by comparing lengths.

python Your answer
words = ["pear", "fig", "watermelon"]
result = 
print(result)

Press Ctrl⌘Enter to check your answer

Challenge 4

Add the values and start the total at 100.

python Your answer
values = [12, 18, 25]
result = 
print(result)

Press Ctrl⌘Enter to check your answer