Python Types
Learn about the basic data types and variable assignment in Python.
We'll cover the following...
Python supports three categories of data types:
- Basic types:
int,float,complex,bool,str,bytes - Container types: list, tuple, set, dictionary
- User-defined types:
class
Basic types
Here are some examples of different basic types:
-
int: It can be expressed in binary, decimal, octal or hexadecimal. Binary starts with0b/0B, octal with0o/0Oand hex with0x/0X, e.g., 0b10111, 156, 0o432, 0x4A3 etc. -
float: It can be expressed in a fractional or exponential form, e.g., 314.1528, 3.141528 ...
Ask