💻 Computer Science · Topic 28 of 80

Lists and Arrays

Lists store ordered collections.

Interactive labDrag the bars to change the data

About this topic

A list or array stores many values in one variable, in order, with each item reached through an index that usually starts at 0. They are used for collections such as scores, names or temperatures. Common operations are accessing an item, changing it, adding, removing, finding the length, searching and sorting.

If scores = [70, 85, 90], then scores[0] is 70 and the last item is at index 2. Loops pair naturally with lists because you can visit every item to compute a total or maximum, for example dividing the total by the length to get an average. Arrays in languages like C have fixed size and a single type, while Python lists can grow and mix types.

Lists organise data in games, spreadsheets and databases, and two-dimensional lists represent grids like chessboards and images. The most common error is going past the end, such as using index 3 in a list of three items, which causes an index error. Another is forgetting that copying a list may only copy a reference, so changes affect both. Check the length before using an index.

Key ideas

  1. Zero-based indexing
  2. append, insert, remove
  3. Loop through items

Quick check

Use cases: where Lists and Arrays helps

Computing ideas run phones, search engines, games and the wider internet.

Frequently asked questions

What is Lists and Arrays?

Lists store ordered collections.

What will I learn in Lists and Arrays?

Zero-based indexing. append, insert, remove. Loop through items.

Is Lists and Arrays part of Computer Science?

Yes. It is one of 80 Computer Science topics on LearnViz HighSchoolEdu, with 3 key ideas, a live animation and a quick check.

Does the Lists and Arrays lab work on a phone or tablet?

Yes. The animation resizes to fit your screen and supports touch, so you can drag, tap and slide with your finger.

How should I study Lists and Arrays?

Read the summary and key ideas first, play with the interactive lab to see the idea in motion, then answer the quick check. If you get a question wrong, go back to the key idea it tests.

Do I need an account, and is my progress saved?

No account is needed. Marking a topic as learned is saved in your own browser, so it stays on that device and is not sent to a server.

More in Computer Science