CS: Arrays and Lists
Storing, accessing, and updating ordered data
Storing, accessing, and updating ordered data
CS - Grade 9-12
- 1
A list named scores stores the values [88, 92, 75, 100, 67]. What value is stored at index 2? Explain how you found it.
- 2
A list named colors starts as ["red", "blue", "green", "yellow"]. After the statement colors[1] = "purple", what is the list?
- 3
A program has the list nums = [4, 8, 15, 16, 23, 42]. Write the value of nums[0] + nums[5] and explain your answer.
- 4
A list named names contains 6 elements. What are the valid index values for this list if the language uses 0-based indexing?
- 5
Explain the difference between an array and a list in many programming languages. Include one example of when a list may be easier to use.
- 6
A list starts as [10, 20, 30]. A program appends 40 to the list. What is the list after the append operation?
- 7
A list named letters starts as ["a", "b", "c", "d"]. A program removes the element at index 2. What is the list after the removal?
- 8
Trace this loop and write the final value of total: nums = [3, 5, 2, 10]; total = 0; for each n in nums: total = total + n.
- 9
Write pseudocode that prints every element in the list temperatures = [72, 68, 75, 70].
- 10
A list named values is [9, 1, 6, 3]. Write pseudocode to find the largest value in the list.
- 11
A program tries to access items[10] when items has length 10. Explain the error.
- 12
A list of test scores is [80, 95, 70, 100, 85]. Write pseudocode to count how many scores are at least 90.
Related Cheat Sheets
More CS Worksheets
CS: Algorithms and Flowcharts
Grade 6-8 · 12 problems
CS: Big-O Notation and Algorithm Efficiency
Grade 9-12 · 12 problems
CS: Binary Numbers and Number Systems
Grade 6-8 · 12 problems
CS: Boolean Logic and Logic Gates
Grade 6-8 · 12 problems
More Grade 9-12 Worksheets
Linear Equations
Math · 8 problems
Cell Biology
Biology · 8 problems
Reading Comprehension
Language Arts · 8 problems
Historical Thinking & Evidence
Social Studies · 8 problems