0
0
Intro to Computingfundamentals~20 mins

Arrays and lists in Intro to Computing - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Array and List Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
trace
intermediate
2:00remaining
Trace the final list after operations
Given the following steps on a list, what is the final list?
my_list = [1, 2, 3, 4]
my_list.append(5)
my_list.pop(1)
my_list.insert(2, 10)
Intro to Computing
my_list = [1, 2, 3, 4]
my_list.append(5)
my_list.pop(1)
my_list.insert(2, 10)
A[1, 2, 10, 3, 4, 5]
B[1, 10, 3, 4, 5]
C[1, 3, 4, 10, 5]
D[1, 3, 10, 4, 5]
Attempts:
2 left
💡 Hint
Remember that pop removes the item at the given index and append adds to the end.
🧠 Conceptual
intermediate
2:00remaining
Understanding list indexing and slicing
What will be the output of the following slicing operation?
numbers = [10, 20, 30, 40, 50, 60]
print(numbers[1:5:2])
Intro to Computing
numbers = [10, 20, 30, 40, 50, 60]
print(numbers[1:5:2])
A[20, 30, 40, 50]
B[20, 40]
C[20, 40, 60]
D[10, 30, 50]
Attempts:
2 left
💡 Hint
Slicing syntax is list[start:stop:step]. It includes start index but excludes stop index.
Comparison
advanced
2:00remaining
Compare list and array behavior
Which statement correctly describes a key difference between arrays and lists in programming?
AArrays can only store elements of the same type, while lists can store elements of different types.
BLists require fixed size at creation, arrays can grow dynamically.
CArrays support appending elements at any position, lists do not.
DLists are stored in contiguous memory locations, arrays are not.
Attempts:
2 left
💡 Hint
Think about type restrictions and flexibility of these data structures.
identification
advanced
2:00remaining
Identify the error in list operation
What error will this code produce?
my_list = [1, 2, 3]
print(my_list[5])
Intro to Computing
my_list = [1, 2, 3]
print(my_list[5])
AIndexError: list index out of range
BTypeError: list indices must be integers
CValueError: invalid index
DSyntaxError: invalid syntax
Attempts:
2 left
💡 Hint
Check if the index 5 exists in the list of length 3.
🚀 Application
expert
3:00remaining
Determine the number of elements after nested list flattening
Given the nested list below, how many elements will the flattened list contain?
nested = [[1, 2], [3, 4, 5], [6], []]

Assuming flattening means combining all inner elements into one list.
Intro to Computing
nested = [[1, 2], [3, 4, 5], [6], []]
A7
B5
C6
D8
Attempts:
2 left
💡 Hint
Count all elements inside each inner list and sum them.