From the course: Programming Foundations: Data Structures (2023)

What is data?

- In computer science, data is information stored or processed by a computer. While that might seem fairly abstract there are actually a lot of data points we use in everyday life. A birthday, that's a data point, latitude and longitude for a specific location. That's a piece of data. The name of a city, whether a store is open or closed, your initials, these are all data points. These can all be considered pieces of data and we store them in different ways within a computer. But how exactly do we represent these in our code or use them in our programs? The short answer is it's a lot of ones and zeros. However, to make it a little easier programming languages have created something called data types that we can use to represent common pieces of data in our code. What are some common types of data? Think numbers, letters, true and false values. In the programs we create, we use and store a lot of these and programming languages have created conventions on how these pieces of data can be described and manipulated in code. We classify different pieces of data with data types based on their value. For example, there's a data type for letters and symbols and there are various data types for numbers. But what is a data type really? Ultimately, a data type provides a set of possible values and if a piece of data is one of these values it's classified as that specific type. So a data type is defined by the possible values it can be, but it is also defined by how we operate on that piece of data. In the most general sense, we can think of whole numbers as a data type. It's a set of possible values that include every whole number between a very high upper limit and a very low, lower limit. Operations wise, we can add numbers, subtract them, and more. In Python, we have four core primitive data types, int, float, boolean, and string. Any whole number is classified as an integer. We represent numbers with decimal points as floats. For a true false value, we classify it as a boolean. To represent textual information, we use the string data type. In fact, you can use the type function in Python to discover how a given variable or value is classified. Unlike other languages, these data types are not explicitly written out with syntax. It's implicit, but just because you aren't writing it out, doesn't mean it won't exist. Data types always exist.

Contents