subject

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.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 16:30
What is one reason why indoor air pollution has become an increasing problem.
Answers: 1
question
Computers and Technology, 23.06.2019 18:00
Apunishment or the threat of punishment used to enforce conformity. select the best answer from the choices provided t f
Answers: 1
question
Computers and Technology, 23.06.2019 18:30
This program should be a short piece of code that prints all of the positive integers from 1 to 100 as described more fully below. the program may contain multiple methods, and if using an oo language, should be contained within a single class or object. the program should be designed so that it begins execution when invoked through whichever mechanism is most common for the implementation language. â–ş print out all positive integers from 1 to 100, inclusive and in order. â–ş print messages to standard output, matching the sample output below. â–ş in the output, state whether the each integer is 'odd' or 'even' in the output. â–ş if the number is divisible by three, instead of stating that the number is odd or even, state that the number is 'divisible by three'. â–ş if the number is divisible by both two and three, instead of saying that the number is odd, even or divisible by three; state that the number is 'divisible by two and three'. â–ş design the logic of the loop to be as efficient as possible, using the minimal number of operations to perform the required logic. sample output the number '1' is odd. the number '2' is even. the number '3' is divisible by three. the number '6' is divisible by two and three.
Answers: 1
question
Computers and Technology, 24.06.2019 23:00
People should never use telepresence when virtually meeting with a group of co-workers. true false
Answers: 1
You know the right answer?
In Python, write a function named teacher that produces a mapping of students' grades. Your function...
Questions
Questions on the website: 13722367