Complete the code to print the first 5 even numbers.
for i in range(1, 11): if i [1] 2 == 0: print(i)
The % operator checks the remainder. If i % 2 == 0, then i is even.
Complete the code to find the sum of numbers from 1 to 5.
total = 0 for num in range(1, 6): total [1]= num print(total)
The += operator adds the right value to the variable on the left.
Fix the error in the code to print numbers from 1 to 5.
for i in [1](1, 6): print(i)
list alone does not generate numbers.str or dict causes errors in loops.The range function generates a sequence of numbers, perfect for loops.
Fill both blanks to create a dictionary of squares for numbers 1 to 5.
squares = {x[1]2: x[2]2 for x in range(1, 6)}The ** operator is used for exponentiation (power) to compute squares.
Fill all three blanks to create a dictionary of uppercase words with their lengths, only for words longer than 3 letters.
result = { [1]: [2] for word in words if len(word) [3] 3}word instead of word.upper() for keys.We use word.upper() for uppercase keys, len(word) for values, and filter words with length greater than 3 using >.
