Python supports several data types that are used to store and manipulate different kinds of data. Here are the main data types in Python:

  1. Numeric Types:
    • int: Integer numbers, e.g., 10, -5, 1000.
    • float: Floating-point numbers, e.g., 3.14, -0.001, 2.5e2 (scientific notation).
  2. Sequence Types:
    • str: Strings, e.g., “hello”, ‘world’, “Python”.
    • list: Ordered collection of items, e.g., [1, 2, 3], [‘apple’, ‘banana’, ‘orange’].
    • tuple: Immutable ordered collection of items, e.g., (1, 2, 3), (‘a’, ‘b’, ‘c’).
  3. Mapping Type:
    • dict: Collection of key-value pairs, e.g., {‘name’: ‘John’, ‘age’: 30, ‘city’: ‘New York’}.
  4. Set Types:
    • set: Unordered collection of unique items, e.g., {1, 2, 3}, {‘apple’, ‘banana’, ‘orange’}.
    • frozenset: Immutable set, similar to set but cannot be modified after creation.
  5. Boolean Type:
    • bool: Represents truth values, either True or False.
  6. None Type:
    • None: Represents absence of a value or null.

These are the built-in data types in Python. Additionally, Python allows defining custom data types using classes, which can represent more complex structures and behaviors. Python’s dynamic typing system allows variables to hold values of any data type, and type conversion functions are available to convert values between different data types when necessary.

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *