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 subtraction or multiplication instead of addition.
✗ Incorrect
The plus operator + adds two numbers together.
2fill in blank
mediumComplete the code to check if 10 is greater than 7.
Python
if 10 [1] 7: print("10 is greater")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using less than or equal instead of greater than.
✗ Incorrect
The greater than operator > checks if the left number is bigger than the right number.
3fill in blank
hardFix the error in the code to multiply two numbers correctly.
Python
product = 4 [1] 6 print(product)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using plus or minus instead of multiplication.
✗ Incorrect
The multiplication operator * multiplies two numbers.
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 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using modulo instead of power, or less than instead of greater than.
✗ 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 with uppercase keys and values greater than 0.
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 lowercase keys or wrong comparison operators.
✗ Incorrect
k.upper() converts keys to uppercase. v is the value. > checks if the value is greater than zero.