Search⌘ K
AI Features

Python Types

Explore Python's data types including integers, floats, complex numbers, booleans, strings, and containers like lists and dictionaries. Understand dynamic typing, variable assignment, and how to inspect data types using the type() function for better coding practices.

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} ...