Skip to content

Instantly share code, notes, and snippets.

@mathnogueira
Last active September 11, 2024 15:53
Show Gist options
  • Save mathnogueira/c241f81f68159095e0f25eb79fbb1653 to your computer and use it in GitHub Desktop.
Save mathnogueira/c241f81f68159095e0f25eb79fbb1653 to your computer and use it in GitHub Desktop.
alg
# [candidato1, candidato2, candidato3, brancos]
votos = [0, 0, 0, 0]
fim = False
while not fim:
voto = int(input("Digite o numero do seu candidato (1, 2, 3); 4 para voto branco; 5 para sair: "))
if voto == 5:
fim = True
continue
if voto < 0 or voto > 5:
print("voto invalido")
continue
votos[voto-1] += 1
total = votos[0] + votos[1] + votos[2]
print("Candidato 1: {:.2f}%".format(votos[0]/total * 100))
print("Candidato 2: {:.2f}%".format(votos[1]/total * 100))
print("Candidato 3: {:.2f}%".format(votos[2]/total * 100))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment