0
0
Intro to Computingfundamentals~10 mins

Why data structures matter for efficiency in Intro to Computing - 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 numbers from 0 to 5.

Intro to Computing
numbers = list(range([1]))
Drag options to blanks, or click blank then click option'
A1
B5
C6
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 5 as the stop value will exclude 5 from the list.
Using 0 as the stop value will create an empty list.
2fill in blank
medium

Complete the code to create a dictionary that maps numbers to their squares for numbers 1 to 5.

Intro to Computing
squares = {x: x[1]2 for x in range(1, [2])}
Drag options to blanks, or click blank then click option'
A**
B*
C6
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using * instead of ** will multiply but not square.
Using range(1, 5) will exclude 5.
3fill in blank
hard

Fix the error in the code to check if a value exists in a list.

Intro to Computing
if [1] in my_list:
    print("Found it!")
Drag options to blanks, or click blank then click option'
Avalue
Bindex
Cin
Dmy_list
Attempts:
3 left
💡 Hint
Common Mistakes
Using the list name instead of the value to check.
Using keywords like 'in' or 'index' incorrectly.
4fill in blank
hard

Fill both blanks to create a set of unique numbers from a list.

Intro to Computing
unique_numbers = set([1])
print(len([2]))
Drag options to blanks, or click blank then click option'
Anumbers
Bunique_numbers
Clist
Dset
Attempts:
3 left
💡 Hint
Common Mistakes
Using list or set as variable names incorrectly.
Mixing up the variable names in the print statement.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension filtering even numbers and mapping to their squares.

Intro to Computing
even_squares = { [1]: [2] for [3] in range(1, 11) if [3] % 2 == 0 }
Drag options to blanks, or click blank then click option'
Ax
Bx**2
Dn
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.
Not squaring the number for the value.