Beginner Fundamentals

Data types

Python has several built-in types. The main ones:

CategoryTypes
Textstr
Numbersint, float, complex
Sequencelist, tuple, range
Mappingdict
Setset, frozenset
Booleanbool
NoneNoneType

Check the type

Use type():

print(type("hi"))   # <class 'str'>
print(type(10))     # <class 'int'>
print(type(3.14))   # <class 'float'>
print(type(True))   # <class 'bool'>

Examples

text = "Hello"      # str
integer = 42        # int
decimal = 3.14      # float
on = True           # bool
items = [1, 2, 3]   # list
data = {"a": 1}     # dict
nothing = None      # NoneType

The type is set automatically when you assign the value.