Python offers a variety of data types to represent different kinds of data. Let's explore them:

Numeric Types

  • int: Represents integer numbers (e.g., 10, -5, 0)
  • float: Represents floating-point numbers (e.g., 3.14, 2.5)
  • complex: Represents complex numbers (e.g., 2+3j)

Text Type

  • str: Represents sequences of characters (e.g., "Hello, world!")

Sequence Types

  • list: Ordered and mutable collection of items (e.g., [1, 2, 3, "apple"])
  • tuple: Ordered and immutable collection of items (e.g., (1, 2, 3))
  • range: Represents an immutable sequence of numbers (e.g., range(5))

Mapping Type

  • dict: Unordered collection of key-value pairs (e.g., {'name': 'Alice', 'age': 30})

Set Types

  • set: Unordered collection of unique elements (e.g., {1, 2, 3})
  • frozenset: Immutable version of set (e.g., frozenset({1, 2, 3}))

Boolean Type

  • bool: Represents truth values (True or False)

Binary Types

  • bytes: Immutable sequence of bytes
  • bytearray: Mutable sequence of bytes
  • memoryview: Object providing a view of the memory of an existing object
Read More....  Python Classes in Mumbai