Questions & AnswersPython Programming

For Georgia Tech CSE 6040 Notebook 1 Part 2 more_exercise, I got an...

Question
Answered step-by-step
Asked by BaronWaterSheep17 on coursehero.com

For Georgia Tech CSE 6040 Notebook 1 Part 2 more_exercise, I got an...

For Georgia Tech CSE 6040 Notebook 1 Part 2 more_exercise, I got an error for  on expected output. Please advise.

Exercise 3 (grade_dicts_test: 2 points). Complete the function build_grade_dicts, again taking grades as a parameter and returning new dictionary, grade_dicts, that maps names of students to dictionaries containing their scores. Each entry of this scores dictionary should be keyed on assignment name and hold the corresponding grade as an integer. For instance, grade_dicts['Thorny']['Exam 1'] == 100. You may find solutions to earlier exercises useful for completing this one. Feel free to use them!

def build_grade_dicts(grades):
   grade_dicts = dict()
   for i in grades[1:]:
       grade_dicts[i[0]] = dict(zip(assignments, [int(j) for j in i[1:]]))    
   return grade_dicts

 

image.png

Image transcription text

In [ 68]: def build_grade_dicts(grades) : grade_dicts = dict() for i in grades [1 : ]: grade_dicts[i[0]] = dict(zip(assignments, [int(j) for j in i[1:]])) return grade_dicts The demo cell below should display { 'Thorny' : {'Exam 1' : 100, 'Exam 2' : 90, 'Exam 3' : 80}, "Mac': {'Exam 1' : 88, 'Exam 2' : 99, 'Exam 3' : 111}, 'Farva" : {' Exam 1' : 45, 'Exam 2' : 56, 'Exam 3' : 67}, "Rabbit' : {' Exam 1' : 59, 'Exam 2' : 61, 'Exam 3' : 67}, 'Ursula': {'Exam 1' : 73, 'Exam 2' : 79, 'Exam 3' : 83}, "Foster': {' Exam 1' : 89, 'Exam 2' : 97, 'Exam 3' : 101} } In [69]: grade_dicts = build_grade_dicts(grades) grade_dicts Out [69]: {'Thorny': {'Exam 1': 100, 'Exam 2' : 90, 'Exam 3': 80}, "Mac': {'Exam 1' : 88, 'Exam 2' : 99, 'Exam 3' : 111}, 'Farva': {' Exam 1' : 45, 'Exam 2' : 56, 'Exam 3' : 67}, "Rabbit' : {' Exam 1' : 59, 'Exam 2' : 61, 'Exam 3' : 67}, 'Ursula' : {'Exam 1' : 73, 'Exam 2' : 79, "Exam 3' : 83}, 'Foster': {'Exam 1' : 89, 'Exam 2' : 97, 'Exam 3' : 101}}...

[{"metadata":{"trusted":true,"nbgrader":{"schema_version":1,"grade":false,"solution":true,"locked":false,"grade_id":"grade_dicts"},"collapsed":true},"cell_type":"code","source":"def build_grade_dicts(grades):\n    grade_dicts = dict()\n    for i in grades[1:]:\n        grade_dicts[i[0]] = dict(zip(assignments, [int(j) for j in i[1:]]))    \n    return grade_dicts","execution_count":68,"outputs":[]}]

 

image.png

Image transcription text

In [70]: import nb_1_2_tester tester = nb_1_2_tester . Tester_1_2_3( ) for _ in range(20) : try : tester . run_test (build_grade_dicts) (input_vars, original_input_vars, returned_output_vars, true_output_vars) = tester . get_test_vars() except : (input_vars, original_input_vars, returned_output_vars, true_output_vars) = tester . get_test_vars() raise print ( 'Passed. Please submit! ' ) AssertionError Traceback (most recent call last) <ipython-input-70-154b64a9fdbe> in <module> 3 for _ in range (20) : try : tester . run_test (build_grade_dicts) (input_vars, original_input_vars, returned_output_vars, true_output_vars) = tester. get_test_vars() except : w/tester_6040. py in run_test(self, func) 34 self . check_modified () # Check to verify inputs were not modified 35 self . check_type() # Check to verify correct output types - - -> 36 self . check_matches ( ) # Check to verify correct output 37 38 # Do not override this method w/nb_1_2_tester. py in check_matches(self) 76 77 def check_matches (self) : ---> 78 assert check_dicts_match (self . returned_output_vars[ 'grade_dicts' ], self . true_output_vars [ 'grade_dicts' ]), 'Your output for "grade_dicts' does not match the expected output. " 79 80 class Tester_1_2_4(ExerciseTester) : AssertionError: Your output for grade_dicts' does not match the expected output....

Answer & Explanation

Solved by verified expert
Answered by ibhdecastro on coursehero.com
<p>sectetur adipiscing<br/>sectetur adipiscing<br/>sectetur adipiscing<br/>sectetur adipiscing elit. Nam lac<br/>sectetur adipiscing elit. Nam lacinia pul<br/>sectetur adipiscing elit. Nam lacin<br/>sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque<br/>sectetur adipiscing elit. Nam lacinia<br/>sectetur adipiscing elit. Nam lacinia pulv<br/>sectetur adipiscing elit. Nam lacinia<br/>sectetur adipiscing elit. Nam lacinia pulvina<br/>sectetur adipiscing elit. Nam lacinia pulvinar tortor n<br/>sectetur adipiscing elit. Nam</p>
CliffsNotes Logo

Unlock access to this and over
10,000 step-by-step explanations

Unlock Explanation

Have an account? Log In

Step-by-step explanation

<p><strong>sectetur adipiscing elit. Nam lacin</strong></p>sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit

Get unstuck with a CliffsNotes subscription

Example CliffsNotes Question and Answer
Unlock every step-by-step explanation, download literature note PDFs, plus more.Get Access

Related Q&A