Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print a friendly greeting in Python.
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 without quotes
✗ Incorrect
In Python, text must be inside quotes to be printed as a message.
2fill in blank
mediumComplete the code to create a list of three fruits.
Python
fruits = [[1]] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Missing commas between items
Not using quotes around strings
✗ Incorrect
Lists need items separated by commas and each item as a string inside quotes.
3fill in blank
hardFix the error in the code to check if a number is even.
Python
if number [1] 2 == 0: print("Even number")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using // which does floor division
Using * or + which are arithmetic but not remainder
✗ Incorrect
The modulus operator % gives the remainder. If remainder is 0, number is even.
4fill in blank
hardFill both blanks to create a dictionary of squares for numbers 1 to 5.
Python
squares = {x: x[1]2 for x in range(1, 6) if x [2] 2 != 0} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using * instead of ** for power
Using == instead of != for odd check
✗ Incorrect
Use ** for power and % to check if number is odd (remainder not zero).
5fill in blank
hardFill all three blanks to filter and transform a dictionary of words and their lengths.
Python
result = [1]: [2] for word in words if len(word) [3] 3}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.upper() changes keys unnecessarily
Using < instead of > in condition
✗ Incorrect
Use the word as key, its length as value, and filter words longer than 3 letters.