Last active
May 22, 2021 18:59
-
-
Save fmasanori/06b0d3af4b398f754e62a7675e155004 to your computer and use it in GitHub Desktop.
Ordena Salários USP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#feito por https://twitter.com/guilhermeslcs | |
class Professor: | |
def __init__(self, nome, instituto, funcao, salario): | |
self.nome = nome | |
self.instituto = instituto | |
self.funcao = funcao | |
self.salario = salario | |
f = open("salarios.txt", "r") | |
professores = [] | |
for line in f.read().split('\n'): | |
splited = line.split(":") | |
if "Nome" in splited[0]: | |
nome = splited[1] | |
elif "Instituto" in splited[0]: | |
inst = splited[1] | |
elif "Função" in splited[0]: | |
func = splited[1] | |
elif "Salário" in splited[0]: | |
salario = float(splited[1].replace(".","").replace(" ","").replace(",",".")) | |
prof = Professor(nome=nome, instituto=inst, funcao=func, salario=salario) | |
professores.append(prof) | |
ordenados = sorted(professores, key=lambda x: x.salario, reverse=True) | |
for prof in ordenados: | |
print("Nome: "+prof.nome) | |
print("Instituto: "+prof.instituto) | |
print("Função: "+prof.funcao) | |
print("Salário: "+str(prof.salario)) | |
print(" ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice! :)