Python: Data Types - Numbers

less than 1 minute read


:information_source: Note: Read the offical docs to get the most updated information.

Data Types

Python has the following data types built-in by default, in these categories:

Basic Types:

  • Boolean Type: bool
  • Numeric Types: int, float, complex Other Built-in Types
  • Text Type: str
  • Sequence Types: list, tuple, range
  • Mapping Type: dict
  • Set Types: set, frozenset
  • Binary Types: bytes, bytearray, memoryview

Boolean

Python represents true and false values with the bool type. There are only two values in this type: True and False. These values can be bound to a variable:

true_variable = True
false_variable = False

Numbers

There are three different kinds of built-in numbers in Python : ints, floats, and complex.

ints

Integers in Python have arbitrary precision, the amount of digits is limited only by the available memory of the host system.

floats

Floating point numbers are usually implemented in Python using a double in C (15 decimal places of precision), but will vary in representation based on the host system and other implementation details. This can create some surprises when working with floats, due to the Floating point.

################################################################################
################################################################################
################################################################################

Resources:

  • https://docs.python.org/3/library/stdtypes.html

Updated:

Leave a Comment