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})
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))
Comments
Leave a comment