...

/

Python Types

Python Types

Learn about the basic data types and variable assignment in Python.

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 with 0b/0B, octal with 0o/0O and hex with 0x/0X, e.g., 0b10111, 156, 0o432, 0x4A3 etc.

  • float: It can be expressed in a fractional or exponential form, e.g., 314.1528, 3.1415282^{2} ...