In: Computer Science
Using a Python environment of your choice –
Gary = {
"name": "Gary",
"homework": [90.0,97.0,75.0,92.0],
"quizzes": [88.0,40.0,94.0],
"tests": [75.0,90.0]
}
Alice = {
"name": "Alice",
"homework": [100.0, 92.0, 98.0, 100.0],
"quizzes": [82.0, 83.0, 91.0],
"tests": [89.0, 97.0]
}
Tyler = {
"name": "Tyler",
"homework": [0.0, 87.0, 75.0, 22.0],
"quizzes": [0.0, 75.0, 78.0],
"tests": [100.0, 100.0]
}
Thanks for the question. Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks! =========================================================================== # Write a function average that takes a list of numbers and returns the ave def average(lst): return float(sum(lst)) / len(lst) # Write a function called get_average that takes a student dictionary def get_average(dict): homework_average = average(dict['homework']) quizzes_average = average(dict['quizzes']) test_average = average(dict['tests']) return 0.1 * homework_average + 0.3 * quizzes_average + 0.6 * test_average # Define a function called get_class_average that has one argument, students. # You can expect students to be a list containing your three students. def get_class_average(students_list): # First, make an empty list called results. results = [] for student in student_list: results.append(get_average(student)) return average(results) Gary = {"name": "Gary", "homework": [90.0, 97.0, 75.0, 92.0], "quizzes": [88.0, 40.0, 94.0], "tests": [75.0, 90.0]} Alice = {"name": "Alice", "homework": [100.0, 92.0, 98.0, 100.0], "quizzes": [82.0, 83.0, 91.0], "tests": [89.0, 97.0]} Tyler = {"name": "Tyler", "homework": [0.0, 87.0, 75.0, 22.0], "quizzes": [0.0, 75.0, 78.0], "tests": [100.0, 100.0]} # Insert one additional (new) dictionary of your choice Marsha = {"name": "Marsha", "homework": [90.0, 77.0, 68.0, 72.0], "quizzes": [6.0, 69.0, 74.0], "tests": [78.0, 80.0]} # Create a new list named students that contains four dictionary items student_list = [Gary, Alice, Tyler, Marsha] # for each student in your students list, print out that student's data, as follows for student in student_list: print('Student Name: {}'.format(student['name'])) print('Homework Scores: {}'.format(' '.join([str(score) for score in student['homework']]))) print('Quizzes Scores: {}'.format(' '.join([str(score) for score in student['quizzes']]))) print('Test Scores: {}\n'.format(' '.join([str(score) for score in student['tests']]))) # Finally, print out the result of calling get_class_average with the students list. print('Class Average: {:.2f}'.format(get_class_average(student_list)))
=======================================================================