Junior — Middle
Can you list the main properties and types of data used in Python?
sobes.tech AI
Answer from AI
In Python, the main data types are divided into several categories:
-
Numeric types:
int— integers, for example, 42float— floating-point numbers, for example, 3.14complex— complex numbers, for example, 1+2j
-
Boolean type:
bool— takes valuesTrueorFalse
-
Sequences:
str— strings, for example, "hello"list— mutable lists, for example, [1, 2, 3]tuple— immutable tuples, for example, (1, 2, 3)
-
Sets:
set— mutable set of unique elementsfrozenset— immutable set
-
Dictionaries:
dict— collection of key-value pairs
-
Special type:
NoneType— the type of theNoneobject, which indicates the absence of a value
All objects in Python have a type, and the type determines what operations can be performed with the object. Types can be mutable (e.g., lists) and immutable (e.g., strings, tuples).