Question
Consider the following scenario about using Python dictionaries: A teacher is using a dictionary to store student grades. The grades are stored as a point
Consider the following scenario about using Python dictionaries:
A teacher is using a dictionary to store student grades. The grades are stored as a point value out of 100. Currently, the teacher has a dictionary setup for Term 1 grades and wants to duplicate it for Term 2. The student name keys in the dictionary should stay the same, but the grade values should be reset to 0.
Complete the setup_gradebook function so that input like {"James": 93, "Felicity": 98, "Barakaa": 80} will produce a resulting dictionary that contains {"James": 0, "Felicity": 0, "Barakaa": 0}. This function should:
1.accept a dictionary old_gradebook variable through the functions parameters;
2.make a copy of the old_gradebook dictionary;
3.iterate over each key and value pair in the new dictionary;
4.replace the value for each key with the number 0;
5.return the new dictionary.
def setup_gradebook(old_gradebook):
# Use a dictionary method to create a new copy of the "old_gradebook".
___
# Complete the for loop to iterate over the new gradebook.
for ___
# Use a dictionary operation to reset the grade values to 0.
___
return new_gradebook
fall_gradebook = {"James": 93, "Felicity": 98, "Barakaa": 80}
print(setup_gradebook(fall_gradebook))
# Should output {'James': 0, 'Felicity': 0, 'Barakaa': 0}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started