Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a list of fruits.
No-Code
fruits = [[1]] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around strings
Using semicolons instead of commas
Not separating items with commas
✗ Incorrect
The list must contain strings with quotes and separated by commas.
2fill in blank
mediumComplete the code to display the first fruit in the list.
No-Code
print(fruits[[1]])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 1 instead of 0 for the first item
Using negative indexes without understanding
Using an index out of range
✗ Incorrect
List indexes start at 0, so the first item is at index 0.
3fill in blank
hardFix the error in the code to display all fruits separated by commas.
No-Code
print([1](", ", fruits))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using split instead of join
Calling join on the list instead of the string
Using append which adds items to a list
✗ Incorrect
The join method combines list items into a string separated by the given string.
4fill in blank
hardFill both blanks to create a dictionary with fruit names as keys and their colors as values.
No-Code
fruit_colors = [1]: [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lists or tuples instead of a dictionary
Not using colons between keys and values
Using square brackets which create lists
✗ Incorrect
A dictionary uses curly braces with key-value pairs separated by colons.
5fill in blank
hardFill all three blanks to create a list of dictionaries, each with a fruit and its color.
No-Code
fruits = [[1], [2], [3]]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a list of strings instead of dictionaries
Not separating items with commas
Using square brackets instead of curly braces for dictionaries
✗ Incorrect
Each item in the list is a dictionary with keys 'name' and 'color'.