Python Data Types

12-17-2020

Types are one the fundamental concepts in Python and any programming language in general. Types are what classify pieces of data as a certain type of information. For example, a number is seen differently than a word. In this article, we will look at the four most common data types in Python.



The Data Types



Integer

The first data type is the integer. An integer is a whole number. For example the numbers here are integers:

1 + 1 = 2

Float

The float can be interpreted as a decimal number. For example, the numbers here are floats:

1.5 + 1.5 = 3.0

Note: Although 3.0 is a whole number, including the ".0" classifies it as a float.


String

The string is a very versatile data type. Generally, strings are used to store words, phrases, or sentences. However, a number can also be of a string type. They are easily identified by their quotation marks. For example, all four of these are strings.

"hello"
"hello, world"
"4"
"4.0"

Note: Although "4" is a number, since it is a string, it does not behave as a number like it's integer counter part.


Boolean

The Boolean is a very specific type of data. In most programming languages, including Python, a piece of data that is of the type Boolean can only either be equal to "true" or "false". More specifically, they are capitalized in Python as:

True
False

Next Steps

Now that you have gone over the basic types in Python, a logical next step would be to learn how they work with variables. Variables allow us to store and manipulate these data types. Check them out here. Good luck!