Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print a greeting message.
Python
print([1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the text.
Trying to print a variable that is not defined.
✗ Incorrect
The print function needs a string inside quotes to display text.
2fill in blank
mediumComplete the code to assign the number 5 to variable x.
Python
x = [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around numbers.
Using variable names instead of values.
✗ Incorrect
To assign a number, write the number without quotes.
3fill in blank
hardFix the error in the code to correctly add two numbers.
Python
result = 3 [1] 4
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using minus or other operators instead of plus.
Forgetting the operator.
✗ Incorrect
The plus sign (+) adds two numbers together.
4fill in blank
hardFill both blanks to create a dictionary with word lengths for words longer than 3 letters.
Python
lengths = {word: [1] for word in words if len(word) [2] 3} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using word instead of len(word) for length.
Using < instead of > for filtering.
✗ Incorrect
We use len(word) to get length and > 3 to filter longer words.
5fill in blank
hardFill all three blanks to create a dictionary with 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() for keys.
Using < or other operators instead of >.
Using k instead of v for values.
✗ Incorrect
Keys are uppercased with k.upper(), values are v, and filter uses > 0.