Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python3 please!! http://cs.gmu.edu/~marks/112/projects/votes.csv http://cs.gmu.edu/~marks/112/projects/abbreviations.csv Candidate: we will use the following representation for a candidate inside our program: a tuple containing these values in this order.

Python3 please!!

http://cs.gmu.edu/~marks/112/projects/votes.csv

http://cs.gmu.edu/~marks/112/projects/abbreviations.csv

image text in transcribed

image text in transcribedimage text in transcribed

Candidate: we will use the following representation for a candidate inside our program: a tuple containing these values in this order. Note that name and party are string abbreviations, and popular_votes and electoral votes are integers. candidate (name, party, popular_votes, electoral_votes) Database1: a "database" of votes can store all candidates' votes for each State. Obviously, a candidate's name may get reused in different States, but never in the same State. Not all candidate names appear in every State. Our database must be a dictionary whose keys are States, and whose values are lists of candidate values. Only candidates with positive number of popular_votes may be present in a State. Empty lists are not allowed as values. Candidates in the same State must be stored alphabetically by their abbreviated name (hint: use insert instead of append when adding items to the list because you can't use sorting functions). votes db- AL: [(Johnson', 'IND', 44467, 0), ('Stein', 'IND', 9391, 0)], 'AK': [('Trump', 'REP', 163387, 9)], VA': [(Clinton', 'DEM', 1981473, 13)] Database2: a "database" of abbreviations will store all abbreviations as a dictionary whose keys are the abbreviated strings and whose values are the equivalent full strings, like in the following sample: abbr db AL': 'Alabama AK 'Alaska', DEM': 'Democratic' REP': 'Republican' Trump: 'Donald Trump Candidate: we will use the following representation for a candidate inside our program: a tuple containing these values in this order. Note that name and party are string abbreviations, and popular_votes and electoral votes are integers. candidate (name, party, popular_votes, electoral_votes) Database1: a "database" of votes can store all candidates' votes for each State. Obviously, a candidate's name may get reused in different States, but never in the same State. Not all candidate names appear in every State. Our database must be a dictionary whose keys are States, and whose values are lists of candidate values. Only candidates with positive number of popular_votes may be present in a State. Empty lists are not allowed as values. Candidates in the same State must be stored alphabetically by their abbreviated name (hint: use insert instead of append when adding items to the list because you can't use sorting functions). votes db- AL: [(Johnson', 'IND', 44467, 0), ('Stein', 'IND', 9391, 0)], 'AK': [('Trump', 'REP', 163387, 9)], VA': [(Clinton', 'DEM', 1981473, 13)] Database2: a "database" of abbreviations will store all abbreviations as a dictionary whose keys are the abbreviated strings and whose values are the equivalent full strings, like in the following sample: abbr db AL': 'Alabama AK 'Alaska', DEM': 'Democratic' REP': 'Republican' Trump: 'Donald Trump

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

2. What process will you put in place to address conflicts?

Answered: 1 week ago