E3.1
lista_de_listas = [[4,6,5,9], [1,0,7,2], [3,4,1,8]]
soma = [sum(lista_de_listas[i]) for i in range(len(lista_de_listas))]
print(soma)
E3.2
lista_de_tuplas = [('Pedro', 1.74, 81), ('Júlia', 1.65, 67), ('Otávio', 1.81, 83)]
terceiro_elemento = [lista_de_tuplas[i][2] for i in range(len(lista_de_tuplas))]
print(terceiro_elemento)
E3.3
lista = ['Pedro', 'Júlia', 'Otávio', 'Eduardo']
tupla_nomes = [(i, lista[i]) for i in range(len(lista))]
print(tupla_nomes)
E3.4
aluguel = [('Apartamento', 1700), ('Apartamento', 1400), ('Casa', 2150), ('Apartamento', 1900), ('Casa', 1100)]
apt = [aluguel[i][1] for i in range(len(aluguel)) if aluguel[i][0] == "Apartamento"]
print(apt)
E3.5
meses = ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez']
despesa = [860, 490, 1010, 780, 900, 630, 590, 770, 620, 560, 840, 360]
despesas_mensais = {mes: valor for mes, valor in zip(meses, despesa)}
print(despesas_mensais)
E3.6
vendas = [('2023', 4093), ('2021', 4320), ('2021', 5959), ('2022', 8883), ('2023', 9859), ('2022', 5141), ('2022', 7688), ('2022', 9544), ('2023', 4794), ('2021', 7178), ('2022', 3030), ('2021', 7471), ('2022', 4226), ('2022', 8190), ('2021', 9680), ('2022', 5616)]
filtro_2022_6000 = [(ano, valor) for ano, valor in vendas if ano == '2022' and valor > 6000]
print(filtro_2022_6000)
E3.7
categorias = ['Hipoglicemia', 'Normal', 'Alterada', 'Diabetes']
glicemia = [129, 82, 60, 97, 101, 65, 62, 167, 87, 53, 58, 92, 66, 120, 109, 62, 86, 96, 103, 88, 155, 52, 89, 73]
rotulagem = [(valor,
categorias[0] if valor <= 70 else
categorias[1] if valor <= 99 else
categorias[2] if valor <= 125 else
categorias[3]) for valor in glicemia]
print(rotulagem)
E3.8
id = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
quantidade = [15, 12, 1, 15, 2, 11, 2, 12, 2, 4]
preco = [93.0, 102.0, 18.0, 41.0, 122.0, 14.0, 71.0, 48.0, 14.0, 144.0]
tabela = [('id', 'quantidade', 'preco', 'total')] + [(id[i], quantidade[i], preco[i], quantidade[i] * preco[i]) for i in range(len(id))]
print(f"{'id':<5} {'quantidade':<12} {'preco':<10} {'total':<10}")
for linha in tabela[1:]:
print(f"{linha[0]:<5} {linha[1]:<12} {linha[2]:<10.2f} {linha[3]:<10.2f}")
E3.9
estados = ['SP', 'ES', 'MG', 'MG', 'SP', 'MG', 'ES', 'ES', 'ES', 'SP', 'SP', 'MG', 'ES', 'SP', 'RJ', 'MG', 'RJ', 'SP', 'MG', 'SP', 'ES', 'SP', 'MG']
filiais_por_estado = {estado: estados.count(estado) for estado in set(estados)}
print(filiais_por_estado)
E3.10
funcionarios = [('SP', 16), ('ES', 8), ('MG', 9), ('MG', 6), ('SP', 10), ('MG', 4), ('ES',9), ('ES', 7), ('ES', 12), ('SP', 7), ('SP', 11), ('MG',8), ('ES',8), ('SP',9), ('RJ', 13), ('MG', 5), ('RJ', 9), ('SP', 12), ('MG', 10), ('SP', 7), ('ES', 14), ('SP', 10), ('MG', 12)]
estados = ['SP', 'ES', 'MG', 'MG', 'SP', 'MG', 'ES', 'ES', 'ES', 'SP', 'SP', 'MG', 'ES', 'SP', 'RJ', 'MG', 'RJ', 'SP', 'MG', 'SP', 'ES', 'SP', 'MG']
colaboradores = {estado: sum(trabalhadores for filial, trabalhadores in funcionarios if filial == estado) for estado in set(estados)}
print(colaboradores)