Summary of the chapter “Data Types in Python”. We looked at different data types and how we can use them in our applications and programs
We have now learned the most basic data types in Python. In programs, data is stored in variables where each variable corresponds to a memory location in the computer. This variable is of a certain data type, for example, integer, string, float or boolean. Since variables can be used over and over again, they become very useful and they form the basis of programming.
We have also looked at how to declare (create) different variables and constants as well as differences between different data types. With these data types mathematical operations can be performed. Many functions are built into Python’s standard library, but there are also modules such as NumPy that give us several functions that facilitate mathematical functions.
It is also possible to compare two different variables between each other. A comparison between two variables always returns True or False. For example, compares if one variable is larger, smaller or as large as another variable.
Finally, we showed why it is important to keep track of the type of data a variable contains. For example, there is a difference between the text string “2” and the number (integer) 2. When comparing two variables, you should therefore be careful that the variables are of the same data type. However, if the variables are not of the same data type, you can convert (cast) the data type to another.