Data Types in Python
There are 4 common data types in Python programming, and this applies to most languages as well. We call the value assigned to these data types a variable, and these variables are how the computer stores and works with data.
- Integer (often abbreviated as int):
An integer is a whole number, meaning it has no fractional or decimal part. For example,7is an integer because there is no decimal point. - Float (short for "floating point"):
A float is a data type that can hold numbers with a decimal point, meaning it can represent fractional values. For example,7.7is a float because it has a decimal part. - String (often abbreviated as str):
A string is a data type used to store text, which can contain multiple characters. For example, if a char is'a', then a string could be"apple"or"ass", meaning it stores more than just a single character. - Boolean (often written as bool):
A Boolean is a data type that has only two possible values:TrueorFalse. It is used to represent whether a condition is true or not. For example:my_favourite_colour_is_purple = True. This means my favourite colour is purple.. Which it is!!!