An introduction to python data types

Hey, guys! Today I am going to talk a bit about some of the common types of data you will encounter in Python. Each of these data types has its place in your code, and some are better for certain jobs than others. So let’s take a look!

we can assign a string to a variable containing some data like we see below:

name = “Logan”

This allows us to store a single piece of data for later retrieval. And we can change it too!

name = “Wolverine”

If this line of code appears later in our document, then the value of our ‘name’ variable is changed from Logan to Wolverine.

This can be useful in your programming, as you have the ability to quickly change your code without a ton of hassle.

variables can also be assigned number values or boolean values. Often when we are working with loops we are going to set an initial value to a variable like ‘i’ or ‘j’, and incrementally add to them as the computer runs through our code.

This is a very common technique and you will definitely be using it if you spend any amount of time programming.

We also have another useful data type that you will be working with a lot that we call a list. I bet you can guess what a lit is, can’t you? Yep, it’s a list of data. They function a lot like variables, only you can store a huge amount of data in them rather than a single element. Let’s see how that looks in practice:

names = [“Logan”, “Wolverine”, “The Hulk”, “etc”]

So now, rather than storing a single piece of data, in this case, a name, we can store multiple values and recall them later in our code. Neat, huh?

Next time, we’ll talk through a few examples on how to work with our different data types, and get to writing a bit of code. See you then!

An introduction to python data types