Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions