0
0
DSA Pythonprogramming~10 mins

Array Declaration and Initialization in DSA Python - Interactive Practice

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

Complete the code to declare an empty list named arr.

DSA Python
arr = [1]
Drag options to blanks, or click blank then click option'
A{}
B()
C[]
Darray()
Attempts:
3 left
💡 Hint
Common Mistakes
Using curly braces {} which creates a dictionary instead of a list.
Using parentheses () which creates a tuple instead of a list.
2fill in blank
medium

Complete the code to create a list numbers with elements 1, 2, and 3.

DSA Python
numbers = [1]
Drag options to blanks, or click blank then click option'
A[1, 2, 3]
B(1, 2, 3)
C{1, 2, 3}
D1, 2, 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses which creates a tuple, not a list.
Using curly braces which creates a set, not a list.
3fill in blank
hard

Fix the error in the code to initialize a list letters with 'a', 'b', 'c'.

DSA Python
letters = [1]
Drag options to blanks, or click blank then click option'
A['a', 'b', 'c']
B('a', 'b', 'c')
C{'a', 'b', 'c'}
D'a', 'b', 'c'
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses which creates a tuple instead of a list.
Using curly braces which creates a set instead of a list.
4fill in blank
hard

Fill both blanks to create a list evens with even numbers from 2 to 10.

DSA Python
evens = [[1] for [2] in range(2, 11, 2)]
Drag options to blanks, or click blank then click option'
Ax
Bi
Cx*2
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable in the output that is not defined in the loop.
Confusing the loop variable name.
5fill in blank
hard

Fill all three blanks to create a list squares of squares of numbers from 1 to 5.

DSA Python
squares = [[1] for [2] in [3](1, 6)]
Drag options to blanks, or click blank then click option'
Anum**2
Bnum
Crange
Dsquare
Attempts:
3 left
💡 Hint
Common Mistakes
Using a function other than range for iteration.
Using a variable name not consistent in output and loop.