Complete the code to calculate the sum of numbers in the list.
numbers = [1, 2, 3, 4, 5] total = [1](numbers) print(total)
The sum() function adds all numbers in the list and returns the total.
Complete the code to calculate the sum of numbers from 1 to 5 using range.
total = [1](range(1, 6)) print(total)
The sum() function can add numbers generated by range().
Fix the error in the code to correctly sum the list elements.
values = [10, 20, 30] total = sum[1]values print(total)
The sum() function requires parentheses around its argument.
Fill both blanks to create a dictionary of word lengths for words longer than 3 letters.
words = ['apple', 'bat', 'carrot', 'dog'] lengths = {word: [1] for word in words if len(word) [2] 3} print(lengths)
We use len(word) to get the length and filter words with length greater than 3 using >.
Fill all three blanks to create a dictionary with uppercase keys and values greater than 10.
data = {'a': 5, 'b': 15, 'c': 20}
result = { [1]: [2] for k, v in data.items() if v [3] 10 }
print(result)The keys are converted to uppercase with k.upper(), values are v, and filtered where v > 10.
