Question: do this in idle in python Aamir Carver Spencer Sparks MA 7 6 5 4 9 4 1 0 1 8 2 7 VA 4

do this in idle in python
Aamir Carver
Spencer Sparks
MA 765494101827
VA 4424941909315
PA 81179896564695
OK 6420691758458
NY 424686482533608
The first line specify the number of candidates (2)
The next 2 lines specify the names of candidates: Aamir Carver and Spencer Sparks
The remaining lines specify information of votes for each state.
The first token (MA, VA, PA, OK, NY) specify the state abbreviation.
The second token (7,4,8,6,4) specify the number of electoral votes in the state.
The remanding tokens specify the number of popular votes for each candidate. Each tokens represent for each candidate in the state. For example of the line [MA 765494101827], in MA, Aamir Carver has 65,494 votes, and Spencer Sparks has 101,827 votes. The number of votes of Spencer Sparks is more than Aamir Carver. Hence, Spencer Sparks wins 7 electoral votes in MA.Place your code in a file named candidates.py.
Here is a step by step guilelines:
Declare variables to hold:
A number of candidates.
A list of electoral vote counters for each candidate.
A list of candidate names.
Store information of votes into variables:
Use for loop to capture state and votes on each line.
Add the number of electoral votes to the candidate who has highest number of popular votes in the state
Print out the name of the candidate who wins the state
Determine the candidate who wins the overall election:
If more than one candidate that has highest number of electoral votes. Let's make this rule simple, the winner will be the candidate with lowest index.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!