Question: Dictionaries & Files. Read the problem and answer the following five questions about it. This code creates a dictionary from a file named dictionary.txt that





Dictionaries & Files. Read the problem and answer the following five questions about it. This code creates a dictionary from a file named dictionary.txt that has 15 words: time year people way day man thing woman life child world school state family student First, make this file dictionary.txt (copy and paste to an IDLE editor) in your directory. Then, put the following code into the same directory. Tamil student First, make this file dictionary.txt (copy and paste to an IDLE editor) in your directory. Then, put the following code into the same directory. # make a dictionary of lists with their word's sizes as keys dictionary - {) max size - 12 try: filein - open ("dictionary.txt", "-") for line in filein: word - line.strip) size - len(word) if size > max size: size - max_size if size not in dictionary.keys(): dictionary (size] - 1 dictionary -get(size).append(word) filein.close() except TOError: print ("Something went wrong with file opening or reading.) for key in range(1, max_size + 1): item - dictionary.get(key, []) print (str(key) str(len(item)) + str(item)) Question 6 3 pt How many lines are printed to the standard output? O 12 O 15 06 O 11 09 GO 0 O 10 O 7 05 nts What does the first number at the beginning of each line in the standard output mean? O a dictionary item a dictionary value O a line number a dictionary key Question 8 3 pts What data types are the values of the dictionary? floats Boolean None integers lists strings Question 9 How many key-value pairs in the dictionary that do not have an empty list? O 15 O 2 4 O un 0 3 O 1 Question 10 What does the second number at the beginning of each line in the standard output mean number of keys in the dictionary number of values in the dictionary the length of the string number of items in the list number of items in the dictionary the length of the list Problem 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
