Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. The Democrat and Republican candidates for presidential election have 5 debates. After each debates a sample of registered voters are polled to see who has won that debate. Write a Python program to do the following. In each of the 5 debates, ask the user to enter the percentage of voters who think the Democrat candidate has won and the percentage of voters who think the Republican candidate has won. If the difference is within 3 percent, the debate is statistically tied. If one candidate beats the other person by more than 3 percent, that candidate is the winner of that debate. Display the winner of each debate or report a tie. After all 5 debates, display the number of debates each candidate has won. Compare these numbers and report which candidate has won more debates, or they have won the same number of debates.
  2.  
  3. CODE:
  4. dem_votes = []
  5. rep_votes = []
  6.  
  7. i = 0
  8. for i in range(5):
  9. demo = input("What percentage of people think Democrat's candidate has won?")
  10. rep = input("What percentage of people think Republican's candidate has won?")
  11. if demo > rep:
  12. dem_votes.append(demo)
  13. if rep > demo:
  14. dem_votes.append(rep)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement