Question: WRITE A FUNCTION FOR EACH OF THE FOLLOWING TASKS ( 1 0 0 Pts ) ( a ) ( 1 0 Pts ) [ Task
WRITE A FUNCTION FOR EACH OF THE FOLLOWING TASKS Ptsa PtsTask Define a function called repeat letters that takes a string and a number n as two parameters and prints the string with every letter repeated n times.Sample inputOutput: printrepeat lettersmedipol mmmeeedddiiipppooolllb PtsTask Define a function called find index which takes as argument a word and a letter. It will return the index of the second occurrence of the letter in the given word.Sample inputOutput: printfind indexwelcomehome ec PtsTask Define a function called list unique that takes a string str as an input, checks all letters of the string, and constructs a list that contains the list of character that appear in str This list should not contain any duplicates.Sample inputOutput: printlist uniqueankaraa n k rd PtsTask Write a function called ngrams list that takes a string and a number n and return the ngrams of the this string as a listSample inputOutput: printngrams listcomputercoommppuutteere PtsTask Imagine a dictionary with the structure student id:student major, student cgpa Assume majors are represented by strings like CoE, EEE, etc. Now define a function avg cgpa by major that takes such a dictionary and a string for major as inputs and returns the average cgpa for all students with that major.Sample inputOutput: In :CoE:EEE:CoE:CoE printavg cgpa by majorIn CoEf PtsTask Define a function called search dict which will take a dictionary and a number as arguments. It will search through dictionarys values, and return True if that number appears in the dictionary as an integer or as a stringSample inputOutput: d Ahmet: Zeynep: Mehmet: printsearch dictdg PtsTask Define a function called hist A it takes a string input and finds which letter exists how many times in this given string.Sample inputOutput: printhist Akara murat kimk: a: r: m: u: i: :h PtsTask Define a function called hist B which takes the Output dictionary given by hist A Task as an input. And create a new dictionary which maps from frequencies to letters.Sample inputOutput: res hist Akara murat kim printhist Bres: u t i: r k m: ai PtsTask Define a function called getTopelements that takes a string as an input and returns the most common letters in that string. If the characters have same frequency, it should return in alfabetical order.Sample inputOutput: printgetTopelementsprogramming Most common three letters are: m a gj PtsTask 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 inputOutput: printcompress dictaaaabbaaabbbbbbcccdababcd
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
