2023 1 Please submit only one zip file including only Python codes with py extension There will | Assignment Collections
Computer Science 2023 Python Homework
2023 1 Please submit only one zip file including only Python codes with py extension There will | Assignment Collections
1.Please submit only one zip file including only Python codes with .py extension.
There will be a separate .py file for each question in the zip file. Submissions in
other formats will not be accepted.
2. Codes are expected to be clear, legible and compact with minimum number of
lines and variables, and proper indentation. Variable names are expected to be
appropriate, meaningful and self-explanatory. Codes will be graded based on
these criteria. A correctly working code does not guarantee full credit.
Que 1. (55 points) Write a Python code that gets a file name from a user using the input
statement and reads it to obtain information about students. Each line of the file
includes information about a different student and has two items separated by a
space character. A file, grades.dat, that includes the names and grades of 10
students as shown below is given as an example. The first item is the student name
and the second item is the grade of that student. The code will read the information
in the file in a dictionary where student names are keys and their grades are values
using a for loop. The second item in each line that represents a grade will be
converted to float when it is read as a value in the dictionary. The code is expected
to print the name and grade of the student that are read in each execution of the
for loop. A grade is considered success if it is 70 or above, and failure if it is below
70. The code will count the number of successes, numSuccesses, and the number
of failures, numFailures. It will print successFailureRatio, which is numSuccesses
divided by numFailures.
Barbara 62.5
John 85.
Marvin 72.5
Lewis 95.
William 65.
Mary 87.5
Sandra 92.5
Jacob 60.
Leigh 75.
Pamela 67.5
Que 2. (45 points) Extend the Python code written in question 1 to raise exceptions for the
following three cases using try and except statements so that it will not crash. The
code is expected to have a separate except statement for each case. The code is
expected to print a relevant error message under each except statement:
a. (15 points) IOError if the file does not exist.
b. (15 points) ValueError if the second item in a line cannot be converted to
float. Assume that each line in the file has definitely two items separated by
a space character, but the second item may not be a number by mistake.
c. (15 points) ZeroDivisionError if there are no failures, which happens when
all grades are 70 or above.
We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.