Sobes.tech
Junior — Middle

What are the main categories of data types in Python?

sobes.tech AI

Answer from AI

In Python, the main categories of data types can be divided into several groups:

  1. Numeric types:

    • int — integers
    • float — floating-point numbers
    • complex — complex numbers
  2. Sequences:

    • list — mutable list
    • tuple — immutable tuple
    • range — range of numbers
  3. Strings:

    • str — sequence of characters
  4. Sets:

    • set — mutable set of unique elements
    • frozenset — immutable set
  5. Dictionaries:

    • dict — key-value mapping
  6. Boolean values:

    • boolTrue or False
  7. Special types:

    • NoneType — type of None

Example of usage:

x = 10          # int
pi = 3.14       # float
name = "Anna"  # str
items = [1, 2, 3]  # list
flags = {"a", "b"}  # set
config = {"key": "value"}  # dict
is_valid = True  # bool

This covers the main data types used in Python.

What are the main categories of data types in Python… - sobes.tech