Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

In the cell below, there is a function that is not operating as anticipated and that has poor code style. determine_letter_grade() is supposed to

In the cell below, there is a function that is not operating as anticipated and that has poor code style. In [100]: #your code here def determine_letter_grade (student_points, possible_points): letter_grades={'A': 

In the cell below, there is a function that is not operating as anticipated and that has poor code style. determine_letter_grade() is supposed to take a student's points received (student_points) on an assignment as well as the possible points the student could have earned (possible_points) and return the letter grade the student earned...but it's not quite functioning as anticipated. More specifically, this function should: calculate the percentage of the possible points the student earned on the assignment (Note: you're only expected to account for percentages between 0 and 100 inclusive...so you don't have to consider 101%, for example.) use the dictionary (letter_grades) provided in the function below to determine what letter grade (the key in the dictionary) the student has earned. Note that the values in the dictionary are the range of possible percentages corresponding to the letter grade. The lower bound should be included in the range while the upper value for each element in the dictionary should not be included in the range for that letter value (i.e. 90% would be an 'A'; 80% would be a 'B', etc.) return the letter grade earned from the function and if the user does not provide a value for possible_points, it should default to 100. For example: determine_letter_grade (student_points determine_letter_grade (student_points determine_letter_grade (student_points Debug, edit, and test the function provided below so that it accomplishes the intended goal. = = break = 10, possible_points 10) would return 89, possible_points 100) would return 5, possible_points 10) would return 'F' = = = def determine_letter_grade (student_points, possible_points): letter_grades={'A': (90,101), 'B': (80,90), 'C': (70,80), 'D': (60,70), 'F': (0,60)} percentage= (student_points/possible_points) for letter in letter_grades: 'A' 'B 1 if percentage =letter_grades [letter] [1]: print (letter_grades [letter]) In [100] #your code here def determine_letter_grade (student_points, possible_points): letter_grades={'A': (90,101), "B":(80,90), 'C': (70,80), 'D':(60,70), 'F':(0,60)} percentage=student_points/possible_points*100 for letter in letter_grades: if percentage >= letter_grades [letter][0] and percentage 1 print (determine_letter_grade (student_points 7 8 ----> 9 a letter break return a /tmp/ipykernel_234/1715616551.py in determine_letter_grade (student_points, possible_points) In [94]: # BE SURE YOUR ANSWER IS IN THE CELL ABOVE = Traceback (most recent call last) = In [72]: assert determine_letter_grade UnboundLocalError: local variable 'a' referenced before assignment 10)) In [73]: assert callable(determine_letter_grade) #hiddon forts ahoak additional gago 1, possible_points 10)) #but you can use this cell to test/execute/check your thinking (optional) #hidden tests to check the specific cases given in the instructions borond what Mas snog ifind in the instruations

Step by Step Solution

3.51 Rating (158 Votes )

There are 3 Steps involved in it

Step: 1

It looks like there are several issues with the provided code and the attempted correct... blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Smith and Roberson Business Law

Authors: Richard A. Mann, Barry S. Roberts

15th Edition

1285141903, 1285141903, 9781285141909, 978-0538473637

More Books

Students explore these related Programming questions