-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13-dicionario.py
More file actions
34 lines (27 loc) · 853 Bytes
/
13-dicionario.py
File metadata and controls
34 lines (27 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
filmInception = {
"title": "Inception",
"yearRelease": 2010,
"imdbRating": 8.8,
"genre": ["Sci-fi", "Action", "Thriller"]
}
print(filmInception)
print(len(filmInception))
print(type(filmInception))
# 1 - Recuperar um elemento do dicionário
print(filmInception["genre"])
print(filmInception.get("imdbRating"))
# 2 - Buscar apenas as chaves do dicionário
print(filmInception.keys())
# 3 - Buscar apenas os valores do dicionário
print(filmInception.values())
# 4 - Buscar itens do dicionário com chave e valor
print(filmInception.items())
# 5 - Adicionar itens no dicionário
filmInception["director"] = "Christopher Nolan"
print(filmInception)
# 6 - Atualizar itens no dicionário
filmInception.update({"imdbRating": 8.7})
print(filmInception)
# 7 - Remover item no dicionário
filmInception.pop("director")
print(filmInception)