Data Types define a particular kind/domain of a data item. They define the type of data a variable is pointing to. They also define the operations allowed on that data type. Python doesn't require declaration of data types like in C/C++/Java (as we saw before variables are just pointers). Any variable can be assigned any data type/object, a string variable can be assigned int
or float
or any other object it doesn't matter. Unlike in Java, there is no final (used for declaring a constant variable) keyword in Python. The constant variables in Python are defined inside another .py file in capital letters and then they are imported inside the current module.
Three types of Data Types in programming.
int
, float
, double (n/a in Python), char (n/a in Python), bool
etc.list
in Python), Record (tuple
in Python), Union (dict
in Python), Strings (str
in Python), Functions, Pointers (variables in Python), Structures (n/a in Python) etc.Mutable and Immutable types in Python.
int
, float
, complex
, bool
, None
, str
, tuple
, frozenset
.list
, dict
, set
.Data types explained in this chapter are int, float, complex, str, bool, byte and User-defined Data Type. Later we'll take a look at the None object and some built-in functions. For simplicity I've arranged the rest of them in the Data Structure section. Alright, let's begin.