zuai-logo
zuai-logo
  1. AP Computer Science Principles
FlashcardFlashcard
Study GuideStudy GuideQuestion BankQuestion BankGlossaryGlossary

What is a list?

A container that holds multiple values called elements.

Flip to see [answer/question]
Flip to see [answer/question]
Revise later
SpaceTo flip
If confident

All Flashcards

What is a list?

A container that holds multiple values called elements.

What is an element (in the context of a list)?

An individual value within a list.

What is an index (in the context of a list)?

The position of an element in a list.

What is data abstraction?

Simplifying data by representing it in a general way.

Give an example of data abstraction using lists.

Representing a to-do list as a single list variable instead of multiple individual string variables.

How can lists be used to store and manage student grades?

A list can hold all grades for a student, allowing easy calculation of average or identifying highest/lowest scores.

How can lists be used to store and manage inventory in a store?

Each item can be an element in a list, storing information like name, quantity, and price.

What is the output of the following code? myList ← [10, 20, 30] print(myList[2])

20

Identify the error in the following code: numbers ← [5, 10, 15] print(numbers[0])

AP Pseudocode list indices start at 1, not 0. Accessing index 0 will cause an error.

What is the output of the following code? names ← [“Alice”, “Bob”, “Charlie”] print(names)

[“Alice”, “Bob”, “Charlie”]

What is the output of the following code? word ← “HELLO” print(word[1])

H