Question: python coding homework CHALLENGES NOT REQUIRED ONLY MAIN QUESTIONS ''' Below, you MUST complete both functions as described in the doc comment below each function

python coding homework

CHALLENGES NOT REQUIRED ONLY MAIN QUESTIONS

''' Below, you MUST complete both functions as described in the "doc comment" below each function declaration.

You also MUST add yourself as a student to the gradebook dictionary. Be sure to give yourself really good grades...... '''

# Here is the data structure you will be working with. # It is a dictionary of students. # Each student contains a dictionary of grades. gradebook = { "Alberta" : { "Test 1": 77, "Test 2": 83, "Test 3": 73, "Final": 85 }, "Bernard" : { "Test 1": 84, "Test 2": 91, "Test 3": 98, "Final": 95 }, "Cindi" : { "Test 1": 100, "Test 2": 95, "Test 3": 98, "Final": 95 }, "Doak" : { "Test 1": 68, "Test 2": 65, "Test 3": 77, "Final": 75 }, "Eunice" : { "Test 1": 82, "Test 2": 85, "Test 3": 81, "Final": 80 }, "Frank" : { "Test 1": 93, "Test 2": 95, "Test 3": 91, "Final": 95 }, "Harriet" : { "Test 1": 100, "Test 2": 99, "Test 3": 100, "Final": 100 }, "Zachary" : { "Test 1": 100, "Test 2": 102, "Test 3": 99, "Final": 1000 } }

def grades_for_student(name): ''' Print out a report of grades for a specified student. Assume that you should use the "gradebook" dictionary defined above as a "global" variable. Not generally a good idea, but we'll run with it.

Your function should:

1) Print out a header row and some +'s (maybe use the '+' * a number trick). 2) Retrieve the dictionary of grades for the specified `name`. Since this is the value in the gradebook dictionary for a given student, you can get this dictionary simply by asking for gradebook[name] (here using the `name` parameter passed in to this function). 3) Iterate through the dictionary of grades. Print each "key" (Test name) and value (Test grade) with a colon (": ") in between.

OPTIONAL CHALLENGE 1: Calculate and print a grade average for the student (as shown in the example). I "rounded" it using formatting...if you can...cool. OPTIONAL CHALLENGE 2: Use f-string formatting to make your report a bit "prettier" and line up (right-aligned is the "standard") all of the numbers.

So for example, calling grades_for_student("Frank") should output as follows:

GRADES FOR FRANK +++++++++++++++++++++ Test 1: 93 Test 2: 95 Test 3: 91 Final: 95

__IF__ you did both challenges, it might look more like:

GRADES FOR FRANK +++++++++++++++++++++ Test 1: 93 Test 2: 95 Test 3: 91 Final: 95 --------------------- AVERAGE: 93.50

''' global gradebook

def grades_for_Test(Test): ''' Print out a report of grades for a specified Test. Again, use the gradebook dictionary defined above as a "global" variable.

Your function should:

1) Print out a header row similar to above. 2) Iterate over each of the students in the gradebook. 3) For each student, print the name and grade for the Test specified in the `Test` parameter. This is a little trickier than the other one. In essence, though, you can do something akin to:

for name in gradebook: grades = gradebook[name] # grades for this student Test_grade = grades[Test] # grade for the specified Test

OPTIONAL CHALLENGE 1: Calculate and print a grade average for the Test (as shown in the example). I "rounded" it using formatting...if you can...cool. OPTIONAL CHALLENGE 2: Use f-string formatting to make your report a bit "prettier" and line up (right-aligned is the "standard") all of the numbers.

So for example, calling grades_for_Test("Test 2") should output as follows:

GRADES FOR TEST 2 +++++++++++++++++++++ Alberta: 83 Bernard: 91 Cindi: 95 Doak: 65 Eunice: 85 Frank: 95 Harriet: 99

...or with the optional challenges...

GRADES FOR TEST 2 +++++++++++++++++++++ Alberta: 83 Bernard: 91 Cindi: 95 Doak: 65 Eunice: 85 Frank: 95 Harriet: 99 --------------------- AVERAGE: 87.57

''' global gradebook pass

### HERE IS THE "MAIN" PART OF THE SCRIPT... ### IT SIMPLY CALLS THE FUNCTIONS YOU COMPLETED ABOVE.

grades_for_student("Frank") print() grades_for_Test("Test 2") print() grades_for_student("Cindi") print() grades_for_Test("Final") print()

''' MY OUTPUT FOR THE ABOVE FOUR FUNCTION CALLS LOOKS AS FOLLOWS...YOURS SHOULD BE VERY SIMILAR (THOUGH YOUR NAME SHOULD BE IN THE LIST OF GRADES FOR EACH TEST):

GRADES FOR FRANK +++++++++++++++++++++ Test 1: 93 Test 2: 95 Test 3: 91 Final: 95

GRADES FOR TEST 2 +++++++++++++++++++++ Alberta: 83 Bernard: 91 Cindi: 95 Doak: 65 Eunice: 85 Frank: 95 Harriet: 99

GRADES FOR CINDI +++++++++++++++++++++ Test 1: 100 Test 2: 95 Test 3: 98 Final: 95

GRADES FOR FINAL +++++++++++++++++++++ Alberta: 85 Bernard: 95 Cindi: 95 Doak: 75 Eunice: 80 Frank: 95 Harriet: 100

'''

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!