Computers and Technology

In Python, write a function named teacher that produces a mapping of students' grades. Your function accepts two parameters: a class roster telling you each student's name and percentage earned in the course, and a grade mapping telling you the minimum percentage needed to earn each unique grade mark. The class roster is a dictionary from students' names (strings) to the percentage of points they earned in the course (integers). The grade mapping is a dictionary from percentages (integers) to grades (strings) and indicates the minimum percentage needed to earn each kind of grade. The task of your function is to look at the student roster and grade mapping and use them to build and return a new dict from students' names to the letter grades they have earned in the class, based on their percentage and the grade mapping. Each student should be given the grade that corresponds to the highest value from the grade mapping that is less than or equal to the percentage that the student earned. Suppose that the class roster is stored in a dictionary variable named roster that contains the following key/value pairs, and that the grade mapping is stored in a dictionary variable named grade_map that contains the key/value pairs below it:

roster:
{'Mort': 77, 'Dan': 81, 'Alyssa': 98, 'Kim': 52, 'Lisa': 87, 'Bob': 43, 'Jeff': 70, 'Sylvia': 92, 'Vikram': 90}
grade_map:
{52': D, '70': C-, '73': C, '76': C+, '80': B-, '84': B, '87': B+, '89': A-, '91': A, '98': A+}
The idea is that Mort earned a C+ because his grade is at least 76% Dan earned a B- because he earned at least 80% and so on. If a given student's percentage is not as large as any of the percentages in the dictionary, give them a default grade of "F". So your function should build and return the following dictionary from students' names to their letter grades when passed the above data:

return value:
{'Mort': 'C+', Dan': 'B-', Alyssa': 'A+', Kim': 'D', Lisa': 'B+', Bob': 'F', Jeff': 'C-', Sylvia': 'A', Vikram': 'A-'}
Though dictionaries often store their elements in unpredictable order, for this problem you should process the grade mapping's key/value pairs in ascending order by keys (percentages).

If either dictionary passed to your function is empty, your function should return an empty dictionary. You should not make any assumptions about the number of key/value pairs in the dictionary or the range of possible percentages that could be in the dictionary.

Constraints: You may create one new dictionary as storage to solve this problem. (This is the dictionary you will return.) You may not declare any other data structures. You can have as many simple variables as you like, such as integers or strings. Do not modify the dictionaries that are passed in to your function as a parameter.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 10:00, serenityharmon1
Hey i just logged on and one of the moderators deleted a bunch of my answers to questions, even though the answers were right and the people it doesn't make sense but if anyone wants to talk about anything just message me lol (this is super random lol)
Answers: 1
image
Computers and Technology, 24.06.2019 08:00, qveenvslayin
How can smart devices benefit businesses, organizations, and social communities in the global marketplace?
Answers: 1
image
Computers and Technology, 24.06.2019 08:30, colebuug9
Aconsumer would pay an extra they used the rent to own program to buy the computer, rather than using cash. for all of the items, is the cheapest option over the life of the contract. the most expensive overall option is to use purchase the item.
Answers: 2
image
Computers and Technology, 24.06.2019 12:00, log40
Jack is assisting his younger sibling mary with her mathematics assignment, which includes a study of the number system. jack explains to mary that whole numbers are counting numbers that could be used to record the number of fruits in a basket. which data type represents whole numbers? a. integers. b.floating-point numbers. c. strings. d.boolean
Answers: 1
Do you know the correct answer?
In Python, write a function named teacher that produces a mapping of students' grades. Your function...

Questions in other subjects:

Konu
Mathematics, 28.07.2019 05:00