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:
-
Numeric types:
int— integersfloat— floating-point numberscomplex— complex numbers
-
Sequences:
list— mutable listtuple— immutable tuplerange— range of numbers
-
Strings:
str— sequence of characters
-
Sets:
set— mutable set of unique elementsfrozenset— immutable set
-
Dictionaries:
dict— key-value mapping
-
Boolean values:
bool—TrueorFalse
-
Special types:
NoneType— type ofNone
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.