Question: (h) (10 Pts) [Task-8] Define a function called hist B which takes the Output dictionary (given by hist A [Task-7]) as an input. And

(h) (10 Pts) [Task-8] Define a function called hist B which takes

(h) (10 Pts) [Task-8] Define a function called hist B which takes the Output dictionary (given by hist A [Task-7]) as an input. And create a new dictionary which maps from frequencies to letters. Sample input/Output: res = hist A("kara murat kim")) print (hist B(res)) {1: ['u', 't', 'i'], 2: ['', ''r', 'k', 'm'], 3: ['a']} (i) (10 Pts) [Task-9] Define a function called get Topelements that takes a string as an input and returns the most common 3 letters in that string. If the characters have same frequency, it should return in alfabetical order. Sample input/Output: print(get Topelements ("programming")) Most common three letters are: m, a, g (j) (10 Pts) [Task-10] Define a function called compress_dict, it compresses the strings that have long sequences of equal characters. The program will accept one string as an argument, and return compressed form of the string. Sample input/Output: print(compress_dict("aaaabbaaabbbbbbcccd")) 4a2b3a5b3c1d

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!