Answer:
Written in Python
parties = []
votes = []
total = 0
for i in range(0,3):
party = input("Party: ")
vote = int(input("Vote: "))
parties.append(party)
votes.append(vote)
total = total + vote
for i in range(0,3):
print(parties[i]+"\t\t\t"+str(votes[i])+"\t\t\t"+str(round((votes[i])*100/total,2))+"%")
Step-by-step explanation:
This declares an empty list for parties
parties = []
This declares an empty list for votes
votes = []
This initializes total votes to 0
total = 0
The following iteration allows user to enter details for party and corresponding votes
for i in range(0,3):
party = input("Party: ")
vote = int(input("Vote: "))
parties.append(party)
votes.append(vote)
This calculates the total vote
total = total + vote
The following iteration prints the required details
for i in range(0,3):
print(parties[i]+"\t\t\t"+str(votes[i])+"\t\t\t"+str(round((votes[i])*100/total,2))+"%")