Advertisement
JorgeJunior-CODES

Q9 - L19

Dec 9th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. print("Qual o melhor Sistema Operacional para o uso?\n")
  2. print("As possiveis respostas sao: \n")
  3. print("1- Windows XP\n2- Unix\n3- Linux\n4- Netware\n5- Mac Os\n6- Outro\nDigite 0 para sair\n")
  4.  
  5. votos = [1] #lista no empty
  6. champs = 0 #recebe o número indice do campeão
  7. campeao = 'nenhum' #recebe o nome do campeão
  8.  
  9. while votos[len(votos)-1] != 0:
  10. voto = int(input("Informe o seu voto: "))
  11. votos.append(voto)
  12.  
  13. #Remove o item '0' da lista na posição dada e o devolve.
  14. votos.pop(0)
  15. votos.pop(len(votos)-1)
  16.  
  17. votosWin = votos.count(1)
  18. votosUni = votos.count(2)
  19. votosLin = votos.count(3)
  20. votosNet = votos.count(4)
  21. votosMac = votos.count(5)
  22. votosOut = votos.count(6)
  23. total = votosWin + votosUni + votosLin + votosNet + votosMac + votosOut
  24.  
  25. for i in range(1, 7):
  26. for x in range(1, 7):
  27. if votos.count(i) > votos.count(x):
  28. champs = i
  29.  
  30. if champs == 1:
  31. campeao = "Windows XP 1500"
  32. elif champs == 2:
  33. campeao = "Unix 3500"
  34. elif champs == 3:
  35. campeao = "Linux 3000"
  36. elif champs == 4:
  37. campeao = "Netware 500"
  38. elif champs == 5:
  39. campeao = "Mac Os 150"
  40. elif champs == 6:
  41. campeao = "Outro 150"
  42.  
  43. porcWin = (float(votosWin)/(len(votos)))*100
  44. porcUni = (float(votosUni)/(len(votos)))*100
  45. porcLin = (float(votosLin)/(len(votos)))*100
  46. porcNet = (float(votosNet)/(len(votos)))*100
  47. porcMac = (float(votosMac)/(len(votos)))*100
  48. porcOut = (float(votosOut)/(len(votos)))*100
  49.  
  50. print("\n\nSistema Operacional - Votos %")
  51. print("Windows XP 1500", porcWin,"%")
  52. print("Unix 3500", porcUni,"%")
  53. print("Linux 3000", porcLin,"%")
  54. print("Netware 500", porcNet,"%")
  55. print("Mac Os 150", porcMac,"%")
  56. print("Outro 150", porcOut,"%")
  57. print("\n\n")
  58. print("Total de", total,"votos")
  59. print("O Sistema Operacional mais votado foi o:", campeao, "com", votosWin, "votos", "correspondendo a", porcWin,"% dos votos." )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement