Question #69000

Write a program that uses the keys(), values(), and/or items() dict methods to find statistics about the student_grades dictionary. Find the following:
Print the name and grade percentage of the student with the highest total of points
Find the average score of each assignment.
Find and apply a curve to each student's total score, such that the best student has 100% of the total points.
student_grades = {
'Andrew': [56, 79, 90, 22, 50],
'Colin': [88, 62, 68, 75, 78],
'Alan': [95, 88, 92, 85, 85],
'Mary': [76, 88, 85, 82, 90],
'Tricia': [99, 92, 95, 89, 99]
}
1

Expert's answer

2017-06-23T09:04:07-0400

Answer on Question #69000 - Programming & Computer Science - Python

Question 69000:

Write a program that uses the keys(), values(), and/or items() dict methods to find statistics about the studentgrades dictionary. Find the following:

* Print the name and grade percentage of the student with the highest total of points

* Find the average score of each assignment.

* Find and apply a curve to each student's total score, such that the best student has 100% of the total points.


studentgrades = {
'Andrew': [56, 79, 90, 22, 50],
'Colin': [88, 62, 68, 75, 78],
'Alan': [95, 88, 92, 85, 85],
'Mary': [76, 88, 85, 82, 90],
'Tricia': [99, 92, 95, 89, 99]
}

Answer:

# py3
def main():
    studentgrades = {
    'Andrew': [56, 79, 90, 22, 50],
    'Colin': [88, 62, 68, 75, 78],
    'Alan': [95, 88, 92, 85, 85],
    'Mary': [76, 88, 85, 82, 90],
    'Tricia': [99, 92, 95, 89, 99]
    }
    print('Ans1')
    # Print the name and grade percentage of the student
    # with the highest total of points
    highest_name = next(iter(studentgrades))
    highest_total_of_points = sum(studentgrades[highest_name])
    for name, lst in studentgrades.items():
        total_of_points = sum(lst)
        if total_of_points > highest_total_of_points:
            highest_name = name
            highest_total_of_points = total_of_points
    print('{}, {:.2f}'.format(highest_name, highest_total_of_points / 500))
    print('Ans2')
    # Find the average score of each assignment
    average_scores = {}
    assignments = ('A1', 'A2', 'A3', 'A4', 'A5')
    #scores = [0 for i in range(5)]
    scores = [0] * 5
    for name in studentgrades.keys():
        lst = studentgrades[name]
        for i in range(5):
            scores[i] += 0.2 * lst[i]
    for i in range(len(assignments)):
        average_scores[assignments[i]] = scores[i]
    for ass, scr in sorted(average_scores.items()):
        print('{}, {:.2f}'.format(ass, scr))
    print('Ans3')
    # Find and apply a curve to each student's total score,
    # such that the best student has 100% of the total points.
    new_student_grades = studentgrades
    highest_grades = studentgrades[highest_name]
    grades = []
    for name, lst in studentgrades.items():
        new_lst = []
        for i in range(len(lst)):
            new_lst.append(lst[i] * (1 / highest_grades[i] * 100))
        new_student_grades[name] = new_lst
    for name, lst in studentgrades.items():
        print('{:8s}: '.format(name) + ', '.join(['{:8.2f}'.format(j) for j in lst]))
main()
# Ans1
# Tricia, 0.95
# Ans2
# A1, 82.80
# A2, 81.80
# A3, 86.00
# A4, 70.60
# A5, 80.40
# Ans3
# Colin : 88.89, 67.39, 71.58, 84.27, 78.79
# Tricia : 100.00, 100.00, 100.00, 100.00, 100.00
# Andrew : 56.57, 85.87, 94.74, 24.72, 50.51
# Mary : 76.77, 95.65, 89.47, 92.13, 90.91
# Alan : 95.96, 95.65, 96.84, 95.51, 85.86
Answer provided by www.AssignmentExpert.com

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Amanda
09.04.24, 06:13

Thank you so much for this. I could not figure the last two out and I will build my knowledge off of these answers. Textbook this comes from doesn't teach anything near enough to figure this out.

LATEST TUTORIALS
APPROVED BY CLIENTS