Middle
What are the main data types in Python?
sobes.tech AI
Answer from AI
In Python, there are several fundamental data types used to store different kinds of values:
- int — integers, for example, 42
- float — floating-point numbers, for example, 3.14
- str — strings, for example, "Hello"
- bool — boolean values: True or False
- list — a mutable ordered collection of elements, for example, [1, 2, 3]
- tuple — an immutable ordered collection of elements, for example, (1, 2, 3)
- dict — a dictionary, a set of key-value pairs, for example, {"key": "value"}
- set — a collection of unique elements, for example, {1, 2, 3}
These types cover most data handling tasks in Python.