Computers store data digitally, as a series of 1s and 0s - these are binary numbers. By contrast, much of our real world is described by analog data (like the frequency of someone's voice, the speed at which a bus is moving, or the exact shade of green you see on a plant). Analog data exist along a continuous range of values. How can computers store complex, real-world data in digital format? The answer is a concept called abstraction.

Real-World Abstraction: Maps
Map of the US
Consider the image of a map to the right. It is clearly a picture of the United States. You know this because you recognize details like the general shape of the country and the individual states. However, this map only shows the 2-letter postal codes for each state and the state boundaries, but far more data is available.

Within every state, you could show information like elevations, bodies of water, cities, or roads. These other details still exist and are part of the country this map represents, but they are not necessary to understand and use the map for some purposes. This map is an excellent example of abstraction - it hides information that is not relevant to make the important details easy to find.

Think about how we use the word "map" to represent this image. The name "map" suggests the image has a collection of data about a location. We could have used a more specific name like "An image of the state borders and postal abbreviations within the United States of America". However, by simply calling it a "map", we use abstraction to hide some of the complex details.

Each state on the map is labeled with a 2-letter postal abbreviation like "AK" for Alaska. When you see "AK", you know that the shorter name represents Alaska. Once again, abstraction has hidden some details but provided us with a shorter or simpler way to represent that information.

Real-World Abstraction: Chairs
Let’s study another example of abstraction. Imagine this sentence in your head: "She walked into the room and sat down in the chair".

Series of unique chairs

Were you able to visualize someone walking into a room and sitting on a chair? You were likely able to picture a scene, even without the enormous amount of detail you would get if actually watching it happen in real life.

However, what did your "chair" look like? Was it made of plastic, wood, or metal? What color was the chair? Your imagined scene probably did not focus on those details, because they were not present in the sentence and were not important. In this way, the word "chair" is an abstraction because it hides the details that are not necessary to understanding the sentence.

Abstraction in Programming
Consider a bus that is moving at exactly 50.1250561723412450192874 miles per hour. It is possible to represent this much detail in a computer program, but is it necessary? A computer program might choose to represent the speed of the bus more simply. Consider the options below.

Representation Description
Fast or slow This option simply categorizes the speed of the bus as "fast" or "slow". It may give you a very general sense of how the bus is moving, but most of the detail is lost. However, a computer could represent this option with a single binary digit that held 0 for slow or 1 for fast.
50 mph This option saves only the integer part of the numeric value (everything to the left of the decimal point). A computer would need to use more than one binary digit to hold this information.
50.125 mph This option saves both the integer part of the numeric value and the first three digits to the right of the decimal point. A computer would need more binary digits than storing just the integer part alone.


We practice abstraction when we hide the details of something to focus on the bigger picture. Programmers will frequently use abstraction to represent complex concepts more simply in computer programs. Abstraction is something you will see throughout this course; it allows us to create programs and work with data without worrying about low-level details.

Programming languages use abstractions to make programming tasks easier. For example, programmers could store or use the number 50 in a Python program, but they may not know exactly how that value is represented internally. Python hides the details of exactly how that number is held in computer memory.
Let's imagine a Python program that needs to store the speed of a bus. Programs will assign names to data values, so we might call our value "busSpeed" and store the value 50 inside. This named location that holds a value is called a variable. You'll start learning to create variables in the next lesson!

Bus Speed Variable

Your program might also want to store measurements of the bus speed at several points on the bus route. Python allows you to create lists, which are named holding areas that contain multiple values. We could create a list named "busSpeeds" to hold all values under one name. You'll learn to work with lists in a later chapter.

Bus Speed List

In both cases, the program code can simply refer to the variable or list by name (busSpeed or busSpeeds) and not worry about how the language stores the values inside the container. This is abstraction at work again!

1. How do computers store information? How is some real-world data different?
2. What does abstraction do?
3. What is one example of how we might represent real-world data abstractly?
4. How might computer programs represent an analog value with abstraction?
5. How do computer languages like Python use abstraction to hide details from the programmer?
6. What is a variable and what does it store?
7. What is a list and what does it store?
8. How do programs abstractly refer to a variable or a list?

1. Computers store information digitally, as a series of 1s and 0s (binary numbers). Real-world data, on the other hand, is described by analog data which exists along a continuous range of values.

2. Abstraction is a concept that hides unnecessary or complex details to focus on the important aspects of something. It allows us to simplify and represent complex concepts more easily.
3. One example of representing real-world data abstractly is using a map. A map may only show certain details like state boundaries and postal codes, while hiding other information like elevations, bodies of water, cities, or roads.
4. Computer programs can represent an analog value with abstraction by simplifying the value. For example, instead of representing the exact speed of a bus, a program may categorize it as "fast" or "slow" or store only the integer part of the speed value.
5. Programming languages like Python use abstraction to hide low-level details from the programmer. For example, Python allows you to create variables and lists to store data values, without worrying about how those values are internally stored in computer memory.
6. A variable is a named location in a computer program that stores a value. It allows programmers to assign names to data values for easy reference and manipulation.
7. A list is a named holding area in a computer program that stores multiple values. It allows programmers to store and work with a collection of values under a single name.
8. Programs abstractly refer to a variable or a list by simply using its name in the program code. Instead of worrying about how the values are stored in computer memory, the program can directly refer to the named variable or list.