Answer to Question #298987 in Python for Michael

Question #298987

Write a python function Count_Freq(A) which take a dictionary containing numbers. The function will return a dictionary containing key as a number and value as frequency defining how many times the number is repeating in the dictionary.

Example-1

Example-2

Input:

{'V': 10, 'VI': 10, 'VII': 40, 'VIII': 20, 'IX': 70, 'X': 80, 'XI': 40, 'XII': 20}

 

Output:

({10: 2, 40: 2, 20: 2, 70: 1, 80: 1})

Input:

{'V': 10, 'VI': 10, 'VII': 10, 'VIII': 10, 'IX': 20, 'X': 30, 'XI': 40, 'XII': 20}

Output:

({10: 4, 20: 2, 30: 1, 40: 1})



1
Expert's answer
2022-02-18T18:30:13-0500
from collections import Counter

a = {'V': 10, 'VI': 10, 'VII': 40, 'VIII': 20, 'IX': 70, 'X': 80, 'XI': 40, 'XII': 20}

values = a.values()
print(Counter(values))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS