In the cell below, there is a function that is not operating as anticipated and that...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
It looks like there are several issues with the provided code and the attempted correct... View the full answer
Related Book For
Smith and Roberson Business Law
ISBN: 978-0538473637
15th Edition
Authors: Richard A. Mann, Barry S. Roberts
Posted Date:
Students also viewed these programming questions
-
What did you think about the two contrasting patterns in this chapter? Do you or someone you know fit one or the other of these patterns? Which pattern do you think is more likely to emphasize...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Differentiate implicitly to find 2x + 5xy + 5y +16y - 8 = 0; dy dx . Then find the slope of the curve at the given point. (-2,0)
-
Calculate the gravitational field vector due to a homogeneous cylinder at exterior points on the axis of the cylinder. Perform the calculation (a) By computing the force directly and (b) By computing...
-
Required: Compute the Drying Department's equivalent units of production for pulping and conversion. Compute the Drying Department's cost per equivalent unit for pulping and conversion. Compute the...
-
Consider the gasoline mileage data in Table B.3. a. Does the correlation matrix give any indication of multicollinearity? b. Calculate the variance inflation factors and the condition number of...
-
Logan White is general manager of Valuepoint Salons. During 2018, White worked for the company all year at a $13,600 monthly salary. He also earned a year-end bonus equal to 15% of his annual salary....
-
1. Describe the advantage of the creation of the Chong-Hua Institution for Economic Research. 2. What is the impact of tariffs imposed on Taiwan's imports by Mainland China? 3. Compare the Economic...
-
E6-2B. Inventory Costing Methods-Periodic The following May data are for an item in Mary's inventory: unit. Method Mary Company uses the periodic inventory system. LO May 1 Beginning inventory, 150...
-
MBI has projected year 1 free cash flow equal to 60 million. MBI has a weighted average cost of capital equal to 12% and a projected growth rate of free cash flows equal to 4%. What do estimate is...
-
If identified goods are destroyed through no fault of either party and risk has not passed to the buyer, the parties are excused from performance. (True/False)
-
Sushi Yo! makes ready-to-eat Asian seafood dishes that are sold in grocery stores. Sushi Yo! and Dragonfly Tea Company comarket their products in Milwaukee. Due to their success, the two firms...
-
When and how does a buyer or lessee pay for goods?
-
Under the doctrine of strict liability, defendants are liable for the results of their acts only if they intended those results. (True/False)
-
Under the UCC, acceptance can be made by any means of communication reasonable under the circumstances. (True/False)
-
First National Bank pays 7.2% interest compounded semiannually. Second National Bank pays 6% interest compounded monthly. a. Calculate the effective annual rate for each bank. Note: Do not round...
-
From a medical tourist perspective, compare Shouldice with the traditional hospital in terms of the key factors of competition. Using Table 15-3, why would Shouldice attract patients from outside the...
-
Discuss the contract liability of a partnership and the partners.
-
Identify and discuss the other methods of complying with the statute of frauds under general contract law and the UCC.
-
. Discuss the duties owed by a partner to her copartners.
-
Determine whether each of the following statements is true or false: Management accountants should be technically proficient, but they dont need strong oral and written communication skills.
-
Determine whether each of the following statements is true or false: Management accountants are now more often looked upon as internal business advisors rather than bean counters recording historical...
-
Determine whether each of the following statements is true or false: The Association of International Certified Professional Accountants (AICPA) issues the Certified Management Accountant (CMA)...
Study smarter with the SolutionInn App