0
0
Intro to Computingfundamentals~10 mins

Choosing the right data structure in Intro to Computing - Interactive Code Practice

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

Complete the code to create a list that can store multiple items.

Intro to Computing
my_collection = [1]
Drag options to blanks, or click blank then click option'
A[]
B{}
C()
D''
Attempts:
3 left
💡 Hint
Common Mistakes
Using curly braces creates a set or dictionary, not a list.
Using parentheses creates a tuple, which is similar but not the same.
2fill in blank
medium

Complete the code to add a new item to the end of the list.

Intro to Computing
my_list = [1, 2, 3]
my_list.[1](4)
Drag options to blanks, or click blank then click option'
Ainsert
Bextend
Cadd
Dappend
Attempts:
3 left
💡 Hint
Common Mistakes
Using insert requires a position index.
Using add is for sets, not lists.
Using extend adds multiple items from another list.
3fill in blank
hard

Fix the error in the code to access the value for key 'name' in the dictionary.

Intro to Computing
person = {'name': 'Alice', 'age': 30}
print(person[1]'name')
Drag options to blanks, or click blank then click option'
A(
B[
C{
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses causes a syntax error.
Curly braces are for creating dictionaries, not accessing values.
4fill in blank
hard

Complete the code to create a dictionary comprehension that maps words to their lengths for words longer than 3 letters.

Intro to Computing
{word: len(word) for word in words if len(word) [1] 3}
Drag options to blanks, or click blank then click option'
A:
B>
C<
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using = instead of : causes syntax errors.
Using < filters shorter words, not longer.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase keys to their values for items with positive values.

Intro to Computing
result = [1]: [2] for k, v in data.items() if v [3] 0}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk
Attempts:
3 left
💡 Hint
Common Mistakes
Using k instead of k.upper() keeps keys unchanged.
Using < filters negative values, not positive.