Home / Expert Answers / Computer Science / use-python-to-solve-the-problem-which-takes-a-list-of-words-as-a-parameter-a-pa719

(Solved): Use python to solve the problem which takes a list of words as a parameter a ...



which takes a list of words as a parameter and returns a dictionary. The function creates a dictionary by looping through eacResult
good 425
hello 532
program 760???????

Use python to solve the problem

which takes a list of words as a parameter and returns a dictionary. The function creates a dictionary by looping through each word in the list and creating a corresponding key : value item. The key of each item in the dictionary is a word, and the value is the sum of the ASCll codes of each letter in the word. For example, the following code fragment: ascii_dict = create_word_ascii_dictionary (['at', 'of']) print(ascii_dict) produces: \( \{ \) 'at' : 213, 'by' : 219 \( \} \) The ascii code of 'a' is 97 , and ' \( t \) ' is 116 (i.e. \( 97+116=213 \) ). The ascii code of ' \( b \) ' is 98, and ' \( y \) ' is 121 (i.e. \( 98+121=219 \) ). Note: - You may use the ord ( letter ) function to get the ASCII code of a letter. - You can assume that the parameter word is not empty and contains lowercase string elements only. For example: Test a_dict = create_word_ascii_dictionary(['hello', 'good', 'program'] for key in sorted(a_dict): print(key, a_dict [key] ) Result good 425 hello 532 program 760


We have an Answer from Expert

View Expert Answer

Expert Answer


Dictionary is a data structure to store data in key-value pairs.
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe