Welcome back! In the previous lesson, we looked at variables and understood how important they are to programming.
But you might have thought of something: variables are great, but we don’t always store the same type of information. For example, the way I store John’s name should be different from the way I store his age. And you are absolutely correct. That’s why we have data types.
In every programming language, including Python, data types determine how information is stored in the computer’s memory. Python comes with many data types, but they can generally be broken down into about 7, 8, or 9 categories, depending on how you want to look at it.
Strings represent text in Python. They are made up of letters, numbers, or characters enclosed in quotes.
"John" or John’s email, you would use a string.Python has three numeric types:
For this course, we’ll focus on integers and floats.
Quick check: How would you store John’s age? As an integer or a float?
👉 Correct answer: Integer – because it doesn’t make sense to say someone is 18.2 years old.
These store a sequence of items. Python has three main sequence types:
Example: If John goes to the supermarket and buys an orange, a carrot, and bread, it makes sense to store them as a list of items, instead of separate strings.
In Python, this is essentially a dictionary. Dictionaries store information as key-value pairs.
Example: If John buys apples and you want to record not just the item but the quantity:
{"apple": 3, "bread": 1, "carrot": 5}
Sets are collections of unique items. They are useful when you don’t want duplicates.
Booleans represent one of two possible values: True or False.
These are extremely important in conditional flows.
Example: In most countries, the legal age is 18. If someone is 18 or older, they can buy alcohol; otherwise, they cannot.
is_of_age = True # or False
The None type represents the absence of a value. It simply means this thing doesn’t exist. You’ll see it used more later in the course.
These are not commonly used in beginner programming but are very useful when working with binary data such as images or files.
As time goes on, you’ll work more with these data types. For now, we’ll focus on the basics.
👉 I hope you’ve gained a clear understanding of Python’s data types. See you in the next lesson!
Not a member yet? Register now
Are you a member? Login now