Complete the code to print numbers from 1 to 3 using a loop.
for i in [1]: print(i)
The range(1, 4) function creates numbers 1, 2, 3 for the loop to print.
Complete the code to calculate the sum of numbers from 1 to 5.
total = 0 for num in range(1, 6): total [1] num print(total)
The += operator adds each number to the total, accumulating the sum.
Fix the error in the code to print each character in the word.
word = 'hello' for [1] in word: print(letter)
The loop variable should be letter to match the print statement.
Fill both blanks to create a dictionary of squares for numbers 1 to 4.
squares = {x: x[1]2 for x in range(1, 5) if x [2] 3}
print(squares)** is used for power, and < filters numbers less than 3.
Fill all three blanks to create a dictionary of uppercase keys and values greater than 1.
result = [1]: [2] for k, v in data.items() if v [3] 1} print(result)
Keys are converted to uppercase with k.upper(), values are v, and filtered with > 1.
