7.6k views
5 votes
A. Write a Python program to match key values in two dictionaries. Input: {'key1': 1, 'key2': 3, 'key3': 2}, {'key1': 1, 'key2': 2} Output: key1: 1 is present in both x and yB. Write a Python program to sort Counter by value. Input: {'Math': 81, Physics':83, 'Chemistry':87) Output: [('Chemistry', 87), ('Physics', 83), ('Math', 81)

User HunterLion
by
4.0k points

1 Answer

2 votes

Answer:

Please find the attachment of the code file and its output:

Step-by-step explanation:

In the first code, two variable "a, b" is defined that holds dictionary value which is defined in the question, in the next step a for loop is declared that hold dictionary key and value and use a method set to check the value is available in the dictionary and use print method to print its value.

In the second code, a package counter is an import as the c for count value, in the next step a variable a is declared, that uses a counter method to hold a dictionary value in its parameter, and in the print method, it uses sort method to print its value.

A. Write a Python program to match key values in two dictionaries. Input: {'key1': 1, 'key-example-1
User Patrick Janser
by
4.1k points