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, 21.06.2019 20:00
2.)how does a graphical user interface (gui) on a touchscreen interface differ from a gui on a desktop or laptop? a.)a finger or stylus is used instead of a pointer. b.) a magic wand is used instead of a pointer. c.)users speak commands instead of using a pointer. d.)users visualize commands instead of using a pointer.
Answers: 1
question
Computers and Technology, 22.06.2019 17:40
Write a modular program (no classes yet, just from what you learned last year), that allows two players to play a game of tic-tac-toe. use a two-dimensional char array with 3 rows and 3 columns as the game board. each element of the array should be initialized with an asterisk (*). the program should display the initial board configuration and then start a loop that does the following: allow player 1 to select a location on the board for an x by entering a row and column number. then redisplay the board with an x replacing the * in the chosen location. if there is no winner yet and the board is not yet full, allow player 2 to select a location on the board for an o by entering a row and column number. then redisplay the board with an o replacing the * in the chosen location. the loop should continue until a player has won or a tie has occurred, then display a message indicating who won, or reporting that a tie occurred. player 1 wins when there are three xs in a row, a column, or a diagonal on the game board. player 2 wins when there are three ox in a row, a column, or a diagonal on the game board. a tie occurs when all of the locations on the board are full, but there is no winner. input validation: only allow legal moves to be entered. the row must be 1, 2, or 3. the column must be 1, 2 3. the (row, column) position entered must currently be empty (i.e., still have an asterisk in it).
Answers: 1
question
Computers and Technology, 22.06.2019 21:10
Dameas communication challenge is due to which factor
Answers: 2
question
Computers and Technology, 22.06.2019 23:30
Select all that apply. which of the following are proofreading options included in microsoft word? spell check find replace grammar check formatting check
Answers: 1
You know the right answer?
In Python, write a function named teacher that produces a mapping of students' grades. Your function...
Questions
question
Geography, 27.03.2021 22:50
question
Biology, 27.03.2021 23:00
question
English, 27.03.2021 23:00
question
Biology, 27.03.2021 23:00
question
Chemistry, 27.03.2021 23:00
question
Mathematics, 27.03.2021 23:00
question
Physics, 27.03.2021 23:00
question
Chemistry, 27.03.2021 23:00
Questions on the website: 13722363