This blog will teach you what data types, variables, and printing are.
I will be making the assumption that you already have some type of program or website for you to code Python with. If not, please find one to do so, I recommend using something like Google Collab.
Variables are going to always be used inside of your python code, so it’s important to know how to use them. Luckily, it’s pretty easy to understand and use. A variable is like a little container that is used to store a type of data. It’s basically just giving a name to some code so that you can easily use that code by just using the name. If I make a variable called numbers and make that equal to 5 + 5, then the variable numbers will be 10, so I can use the name numbers for other things later on. I can do numbers + 5 so that it will equal to 15. Examples of this will be shown in the data type portion, so stay tuned.
To quickly explain what a data type is, it’s the different types of ways that data values are stored, used, and processed in coding languages. Things like numbers have their data type, while things like words and sentences use a different type of data type. Different data types cannot always be combined, but some can be converted to other types.
There are a good amount of data types used in Python, but the main ones that you will be using are Strings, Integers, Floats, Booleans, and List. These data types will be used in almost every bit of code that you will be doing in Python.
The String data type is really simple. It is the data type that is used to store text such as sentences, numbers, periods, etc… The numbers stored as a String are different than the ones stored as an Integer or Float. To show that something is a String, you have to use quotation marks.
The number based data types you will be using are Integers and Floats. Integers are just whole numbers while Floats are numbers that use decimals. Numbers and decimals can be put as a string, but it can’t be used the same way as when it’s not a string. You can’t add string “5” and integer 5 because strings can’t be added up like Integers can, and you can’t add a string to an integer. These rules apply to Floats as well.
Booleans are pretty different from the other data types that I just mentioned. The way they work is by taking in some kind of comparison, then return True or False depending on the comparison. You use comparison operators(<, >, and ==) to do your comparisons. This data type is going to be used a lot later on, but for now, you probably won’t be using it all too much.
List are used as a way to store multiple different data types all into one. Image it like a box that you can use to store everything else. The stuff in the box can easily be called on and used when needed while ignoring or not affecting the other things in the box. It is a really good means to store a lot of data all in one easy to access place. List use brackets() to hold all of its contents. Each content must be separated by a comma.
Printing is really simple. It’s just a pre-made function in Python that is used to display the output of the code that is in it. You can use it to display sentences from Strings, numbers from Integers, contents from List, etc… If you want to see what the actual output of your code is, you gotta use print so that you can visibly see it.
Thanks for taking the time to read my blog :)
If you have more time, check out my other blogs in the links down below.