Iniciante Fundamentos
Tipos de dados
Python tem vários tipos embutidos. Os principais:
| Categoria | Tipos |
|---|---|
| Texto | str |
| Números | int, float, complex |
| Sequência | list, tuple, range |
| Mapa | dict |
| Conjunto | set, frozenset |
| Booleano | bool |
| Nulo | NoneType |
Descobrir o tipo
Use type():
print(type("oi")) # <class 'str'>
print(type(10)) # <class 'int'>
print(type(3.14)) # <class 'float'>
print(type(True)) # <class 'bool'>
Exemplos
texto = "Olá" # str
inteiro = 42 # int
decimal = 3.14 # float
ligado = True # bool
lista = [1, 2, 3] # list
dados = {"a": 1} # dict
nada = None # NoneType
O tipo é definido automaticamente ao atribuir o valor.