Question: Python Question. Can you explain thoroughly Here is a text file, called animals.txt. Dog goes woof Cat goes meow Bird goes tweet and mouse goes

Python Question. Can you explain thoroughly

Python Question. Can you explain thoroughly Here is a text file, called

Here is a text file, called animals.txt. Dog goes woof Cat goes meow Bird goes tweet and mouse goes squeek Cow goes moo Frog goes croak and the elephant goes toot Ducks say quack and fish go blub and the seal goes ow ow ow But there's one sound - That no one knows What does the fox say? The file is stored in the same directory as a Python program, shown below. mydict = {} myfile = open("animals.txt", 'r') for line in myfile: line = line.rstrip() words = line.split() count = 0 for word in words: if word == "goes" or word == "say" or word == "go": mydict[words[count - l].lower()] = words[count + 1] count += 1 myfile.close () if "fox" in mydict.keys(): print("What does the fox say?") print("The answer is:", mydict["fox"]) else: print("It will remain a mystery ellipsis") What does the program display when it has been executed

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!