Python code discussion question

Help with python discussion question and a code with a paper. see attachment

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Discussion question
What are exceptions and how does exception handling allow programmers to deal with them?
How is the try statement used? Provide an example.
How are the else and finally clauses used? Provide examples.
Assignment 4.
For this assignment, you’ll have the option to complete either Programming Project #3
(Baseball) on page 238 or Programming Project # 4 on page 240.
Students will develop a simple program written in Python to solve a problem statement provided by the instructor.
The program must include 20 to 50 instructions (excluding comments) that include sequential, conditional and/or
iterative programming structures, and customized and/or built-in functions from standard libraries to convert input
into required output and apply the following concepts: Reading a file or set of files, Processing a file, Outputting a
file, and Exception Handling. Students must provide evidence that they have followed all stages of the Programming
Lifecycle Process, including: Problem Statement, Problem Analysis, Logical Design, Coding, Editing (Debugging
and Testing), and Documentation. Debugging log must be included as an appendix and will include sorted date and
time stamps. Students will also write a brief reflection (one or two paragraphs) about new skills or insights they learned
about programming from developing this program and how they can apply them to their current or future work.
All assignments should include all of the sections listed in the rubric and shown
below:
Please include comments in the code to explain what you are doing
1.
2.
3.
Problem statement – Describe the problem in your own words.
Problem Analysis – Use the input-process-outcome model described by Schneider.
Logical Design – Use tools (pseudocode, flow charts, etc.) to map out processing in line with the
problem analysis.
4. Coding – Translate pseudocode in Python code. Make sure to include comments to explain what
is happing.
5.
6.
7.
Correcting/debugging and Testing – Error log should include iterative
updates/changes.
Documentation (beyond comments in the code).
Reflection – Lessons learned about programming in the course of doing the
assignment.
E:
240
Chapter 5 Processing Data
Q
4. U.S. Senate The file Senatel13.txt contains the members of the 113th U.S. Senate-
that is, the Senate prior to the November 2014 election. Each record of the file consists
of three fields-name, state, and party affiliation. Some records in the file are as follows:
Richard Shelby, Alabama, R
Bernard Sanders, Vermont, I
Kristen Gillibrand, New York,
The file RetiredSen.txt contains the records from the file Senatel13.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
(a) Write a program that uses the three files above to create the file Senatel14.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).
(6) Write a program that determines the number of senators of each party affiliation.
See Fig. 5.49.
(c) Write a program that determines the number of states whose two senators have
the same party affiliation.
(d) Write a program that asks the user to input a state, and then displays the two sena-
tors from that state. See Fig. 5.50.
Party Affiliations:
Republicans: 54
Democrats: 44
Independents: 2
Enter the name of a state: Maryland
Benjamin Cardin
Barbara Mikulski
FIGURE 5.49 Outcome of Programming
Project 4(b).
FIGURE 5.50 Outcome of Programming
Project 4(d).
referred to as curving grades.
3. Baseball The file ALE.txt contains the information shown in Table 5.6. Write a pro-
gram to use the file to produce a text file containing the information in Table 5.7. In
the new file, the baseball teams should be in descending order by the percentage of
games won.
TABLE 5.6
American League East games won and lost in 2014.
Won
Lost
Team
96
Baltimore
Boston
New York
Tampa Bay
Toronto
71
84
77
83
66
91
78
85
79

Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER