0
0
Pythonprogramming~10 mins

Why lists are used in Python - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a list of fruits.

Python
fruits = [[1]]
Drag options to blanks, or click blank then click option'
A'apple', 'banana', 'cherry'
B'apple banana cherry'
C'apple'; 'banana'; 'cherry'
D'apple' + 'banana' + 'cherry'
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Forgetting commas between items
Using spaces instead of commas
Using plus signs to join items
2fill in blank
medium

Complete the code to access the first item in the list.

Python
first_fruit = fruits[[1]]
Drag options to blanks, or click blank then click option'
A1
B-1
C0
D2
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using 1 instead of 0 for the first item
Using negative indexes without understanding
3fill in blank
hard

Fix the error in the code to add an item to the list.

Python
fruits.[1]('orange')
Drag options to blanks, or click blank then click option'
Aadd
Bextend
Cinsert
Dappend
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using 'add' which is not a list method
Using 'extend' which expects an iterable
Using 'insert' without specifying position
4fill in blank
hard

Fill both blanks to create a list of squares for numbers greater than 3.

Python
squares = [x[1]2 for x in range(1, 6) if x [2] 3]
Drag options to blanks, or click blank then click option'
A**
B>
C<
D*
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using multiplication instead of power
Using less than instead of greater than
5fill in blank
hard

Fill all three blanks to create a dictionary of uppercase words with their lengths if length is more than 4.

Python
result = [1]: [2] for word in words if len(word) [3] 4}
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
C>
Dword
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using word instead of word.upper() for keys
Using < instead of > for filtering
Using word instead of len(word) for values