Complete Lab 11 first.
Ex. 1. a. Continue the script word_dict_class.py that we started in the last class. Convert the function printing a random definition written for Homework 10 into a class method and add a call to it in the main section.
Add the following functions to the class:
b. Define a class method called print_in_order with no other parameters but the self. This function should print all the keywords and definitions in the alphabetical order of the keywords. For this, store the result of the keys() function applied to the dictionary into a local variable, sort it, and then do a for loop for all the keys in this sorted list, printing them out with the definition. You can use the built-in function sort().
c. Define a search function that looks for keywords containing a particular word and another one looking for definitions containing a particular word. Suppose that word is the term that we're looking for and s is a keyword or a definition. Then the function find(s, word) will return 0 or a positive number if the word is a substring of s, and -1 if it is not. You just have to print all of those for which the result is not -1. This function is defined in the module string.
For example, if we are looking for the word "program" in the keywords, we should find both "program" and "programming language".
Add a couple of examples of calling this function in the main section.
Send me: The modified script word_dict_class.py.