Practice Array in CS Thinking
Use these practice problems to test your method after reviewing the concept explanation and worked examples.
Quick Recap
An ordered collection of values stored together and accessed by their numeric index position.
A numbered list. Item 0, item 1, item 2... Access any by its number.
Example 1
easyAn array `scores` contains [85, 92, 78, 95, 88]. What is scores[0]? What is scores[3]? How many elements are there?
Example 2
mediumWrite pseudocode to find the sum of all elements in an array `nums = [4, 7, 2, 9]`.
Example 3
mediumGiven array `names = ['Alice', 'Bob', 'Charlie']`, what is names[1]? What happens if you access names[3]?
Example 4
mediumGiven `scores = [12, 15, 9, 20]`, what are `scores[0]` and `scores[3]`, and what happens if code tries to read `scores[4]`?