Question: In this assignment you have to write a program that displays administrative information about students in the course Programming for Artists. Data about those students
In this assignment you have to write a program that displays administrative information about students in the course Programming for Artists. Data about those students is once again stored in a file.
This is an example of such a file:
Piet van Gogh
;Vincent Appel,Johannes Mondriaan
Karel van Rijn
;
Herman Vermeer
;Johannes Brood
Johannes Brood
;Herman Vermeer
As you can see, this file contains two different types of lines. The first type of line is similar to the types of line that was used in the Geography Grades assignment. It contains the grades of a student, and has the following structure:
You have to calculate the final grade of the student. Similar to the Geography Grades assignment, all grades have the same weight. There is however a small change in the way that the final grade is determined:
If the average grade is and the final grade will be noted as
In all other cases, the final grade will be the average grade, rounded to the nearest half.
The second type of line contains information about which students handed in programs that are similar to the student of the previous line. It has the following structure:
numbers separated by equals signs;
The first numbers are the similarity scores. These scores represent the number of programs matching a certain percentage of the current program in steps of This means the first numbers indicates the matches from and the last number indicates the matches from
Since this is not easy to read, you have to convert these numbers to a graph according to these rules:
If there are matches, display an underscore:
If there are less than matches, display a minus sign:
If there are or more matches, display a caret:
The names of the students after the semicolon are the names of the students with matches in the final categories. The names of these students should be printed under the graph. If there are no matches, the program should printNo matches found".
The output for the file shown above should be as follows:
Piet van Gogh has an average of
Vincent Appel
Johannes Mondriaan
Karel van Rijn has an average of
No matches found
Herman Vermeer has an average of
Johannes Brood
Johannes Brood has an average of
Herman Vermeer
this is my code but i dont understand whats wrondmissing
def sumgradesgrades:
result
for grade in grades:
result floatgrade
return result
def calculatefinalgradegrades sumgrades:
if sumgrades :
return
averagegrade sumgrades lengrades
if averagegrade :
finalgrade
else:
finalgrade intfloataveragegrade
return finalgrade
def processlinegradesline:
parts line.split
name parts
grades partssplitstrip
sumGrades sumgradesgrades
finalgrade calculatefinalgradegrades sumGrades
return name, finalgrade
def processlinesimilarityline:
parts line.split;
similarityscores partssplit
matches partssplit
return similarityscores, matches
graph
for score in similarityscores:
score intscore
if score :
graph
elif score :
graph
else:
graph
return graph
filename inputEnter a file name:
file openfilenameread
lines file.splitlines
i
while i lenlines:
line linesi
if in line:# if so it's a grades line
name, finalgrade processlinegradesline
if finalgrade :
finalgradestring
else:
finalgradestring f finalgrade
print s has an average grade of sname finalgrade
if i lenlines and in linesi :
i
graph, matches processlinesimilaritylinesi
printgraph
if matches:
print
joinmatches
else:
print No matches found"
i
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
