Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started