-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path09t1q5.py
55 lines (50 loc) · 1.42 KB
/
09t1q5.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
def carrega_cidades():
resultado = []
with open('cidades.csv', 'r', encoding='utf-8') as arquivo:
for linha in arquivo:
uf, ibge, nome, dia, mes, pop = linha.split(';')
resultado.append(
(uf, int(ibge), nome, int(dia), int(mes), int(pop))
)
arquivo.close()
return resultado
def nomesMeses(mes):
if mes == 1:
return 'JANEIRO'
elif mes == 2:
return 'FEVEREIRO'
elif mes == 3:
return 'MARÇO'
elif mes == 4:
return 'ABRIL'
elif mes == 5:
return 'MAIO'
elif mes == 6:
return 'JUNHO'
elif mes == 7:
return 'JULHO'
elif mes == 8:
return 'AGOSTO'
elif mes == 9:
return 'SETEMBRO'
elif mes == 10:
return 'OUTUBRO'
elif mes == 11:
return 'NOVEMBRO'
elif mes == 12:
return 'DEZEMBRO'
def aniversario(mes,pop):
retorno = ''
cidades = carrega_cidades()
for ci in cidades:
if ci[4] == mes and ci[5] > pop:
retorno += (f'{ci[:][2]}({ci[:][0]}) tem {ci[:][5]} habitantes e faz aniversário em '
f'{ci[:][3]} de {nomesMeses(mes).lower()}.\n')
return retorno.strip()
def main():
mes = int(input())
pop = int(input())
print(f'CIDADES COM MAIS DE {pop} HABITANTES E ANIVERSÁRIO EM {nomesMeses(mes)}:')
print(aniversario(mes,pop))
if __name__ == '__main__':
main()