Question: Write a Python Programming. (I am able to do a & b but stuck at c & d, please answer c & d) U.S. Senate?The

Write a Python Programming. (I am able to do a & b but stuck at c & d, please answer c & d)

U.S. Senate?The file Senate113.txt contains the members of the 113th U.S. Senatethat is, the Senate prior to the November 2014 election. Each record of the file consists of three fieldsname, state, and party affiliation.3 Some records in the file are as follows:

3We refer to anyone who is neither a Republican nor a Democrat as an Independent.

Richard Shelby,Alabama,R Bernard Sanders,Vermont,I Kristen Gillibrand,New York,D

The file RetiredSen.txt contains the records from the file Senate113.txt for senators who left the Senate after the November 2014 election due to retirement, defeat, death, or resignation. Some records in the file are as follows:

John Rockefeller,West Virginia,D Tom Coburn,Oklahoma,R Carl Levin,Michigan,D

The file NewSen.txt contains records for the senators who were newly elected in November 2014 or who were appointed to fill the seats of senators who left after the November 2014 election. Some records in the file are as follows:

Shelly Capito,West Virginia,R Steve Daines,Montana,R Gary Peters,Michigan,D

Write a program that uses the three files above to create the file Senate114.txt that contains records (each consisting of three fields) for the members of the 114th Senate where the members are ordered by state. Use this file in parts (b), (c), and (d).

Write a program that determines the number of senators of each party affiliation. See Fig. 5.49.

Write a program that determines the number of states whose two senators have the same party affiliation.

Write a program that asks the user to input a state, and then displays the two senators from that state. See Fig. 5.50.

Party Affiliations: Republicans: 54 Democrats: 44 Independents: 2

FIGURE 5.49 Outcome of Programming Project 4(b).

Enter the name of a state: Maryland Benjamin Cardin Barbara Mikulski

FIGURE 5.50 Outcome of Programming Project 4(d).

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 Databases Questions!