# 3.2 Data Abstraction

## Enduring Understanding

To find specific solutions to generalizable problems, programmers represent and organize data in multiple ways.

## Learning Objective

Represent a list or string using a variable. 

## Essential Knowledge

A list is an ordered sequence of elements. For example,

\[value1, value2, value3, ...]

describes a list where value1 is the first element, value2 is the second element, value3 is the third element, and so on.

An element is an individual value in a list that is assigned a unique index.

An index is a common method for referencing the elements in a list or string using natural numbers.

A string is an ordered sequence of characters.

## Learning Objective

For data abstraction:&#x20;

a. Develop data abstraction using lists to store multiple elements.

b. Explain how the use of data abstraction manages complexity in program code. 

## Essential Knowledge

Data abstraction provides a separation between the abstract properties of a data type and the concrete details of its representation.

Data abstractions manage complexity in programs by giving a collection of data a name without referencing the specific details of the representation.

Data abstractions can be created using lists.

Developing a data abstraction to implement in a program can result in a program that is easier to develop and maintain.

Data abstractions often contain different types of elements.

The use of lists allows multiple related items to be treated as a single value. Lists are referred to by different names, such as array, depending on the programming language.

{% hint style="info" %}
Exclusion Statement: The use of linked lists is outside of the scope of this course and the AP Exam.
{% endhint %}

The exam reference sheet provides the notation

\[value1, value2, value3, ...]

Text:

aList <-- \[value1, value2, value3, ...]

Block:

<figure><img src="/files/jTKIlzQNBYOJDbW6MwT9" alt=""><figcaption></figcaption></figure>

creates a new list that contains the values value1, value2, value3, and ... at indices 1, 2, 3, and ... respectively and assigns it to aList.

Text:

aList <-- \[]

Block:

<figure><img src="/files/frtM0HNWiIMbku3E6GCz" alt=""><figcaption></figcaption></figure>

creates a new empty list and assigns it to aList.

Text:

aList <-- bList

Block:

<figure><img src="/files/aRsJChz5h8g3WoRVxVhq" alt=""><figcaption></figcaption></figure>

assigns a copy of the list bList to the list aList. For example, if bList contains \[20, 40, 60], then aList will also contain \[20, 40, 60] after the assignment.

The exam reference sheet describes a list structure whose index values are 1 through the number of elements in the list, inclusive. For all list operations, if a list index is less than 1 or greater than the length of the list, an error message is produced and the program will terminate.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.csprinciples.com/big-idea-3/3.2-data-abstraction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
