-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex4.py
More file actions
38 lines (34 loc) · 829 Bytes
/
ex4.py
File metadata and controls
38 lines (34 loc) · 829 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
35
36
37
38
#Vou tratar os dados fornecidos como dicionários
lista = [
{
"estado": "SP",
"faturamento": 67836.43
},
{
"estado": "RJ",
"faturamento": 36678.66
},
{
"estado": "MG",
"faturamento": 29229.88
},
{
"estado": "ES",
"faturamento": 27165.48
},
{
"estado": "Outros",
"faturamento": 19849.53
}
]
def get_total_profit(list):
total_profit = 0
for estado in list:
total_profit += float(estado["faturamento"])
return total_profit
def get_state_relevance(list):
total = get_total_profit(list)
for estado in list:
estado["porcentagem"] = f"{100 * float(estado['faturamento']) / float(total)} %"
return list
print(get_state_relevance(lista))