Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add two numbers and print the result.
Python
result = 5 [1] 3 print(result)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' will subtract instead of add.
Using '*' or '/' will multiply or divide, not add.
✗ Incorrect
The plus sign + adds two numbers together.
2fill in blank
mediumComplete the code to multiply two numbers and print the result.
Python
result = 7 [1] 4 print(result)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' adds numbers instead of multiplying.
Using '/' divides numbers, not multiply.
✗ Incorrect
The asterisk * multiplies two numbers.
3fill in blank
hardFix the error in the code to correctly divide two numbers and print the result.
Python
result = 10 [1] 2 print(result)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' multiplies instead of dividing.
Using '+' or '-' changes the operation to addition or subtraction.
✗ Incorrect
The forward slash / divides the first number by the second.
4fill in blank
hardFill both blanks to create a dictionary of squares for numbers greater than 3.
Python
squares = {x: x[1]2 for x in range(1, 6) if x [2] 3}
print(squares) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' instead of '**' will add 2 instead of squaring.
Using '<' instead of '>' will select numbers less than 3.
✗ Incorrect
The operator ** raises a number to a power. The operator > checks if a number is greater than another.
5fill in blank
hardFill all three blanks to create a dictionary of uppercase keys and values greater than zero.
Python
result = [1]: [2] for k, v in data.items() if v [3] 0}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
k instead of k.upper() keeps keys lowercase.Using '<' instead of '>' filters wrong values.
✗ Incorrect
k.upper() converts keys to uppercase, v is the value, and > filters values greater than zero.