Question: 1 {'article': ['the', 'a', 'one', 'few', 'any'], 2 'noun': ['boy', 'girl', 'food', 'cat', 'city', 'car'], 3 'verb': ['crossed', 'slipped', 'hit', 'walked', 'jumped'], 4 preposition':

1 {'article: ['the', 'a', 'one', 'few', 'any'], 2 'noun': ['boy', 'girl', 'food', 'cat', 'city', 'car'], 3

1 {'article': ['the', 'a', 'one', 'few', 'any'], 2 'noun': ['boy', 'girl', 'food', 'cat', 'city', 'car'], 3 'verb': ['crossed', 'slipped', 'hit', 'walked', 'jumped'], 4 preposition': ['to', 'from', 'over', 'under', 'in', 'on'] Write a python function that uses random number generation to create sentences. The program should use a dictionary of lists with the keys article, noun, verb, and preposition as indicated below. The program should create a sentence by selecting a word at random from each array in the following order: article, noun, verb, preposition, article, and noun. As each word is picked, it should be concatenated to the previous words. The words should be separated by spaces. When the final sentence is output, it should start with a capital letter and end with a period. The function should generate n such sentences, where n is an input to the function. Then, the function should concatenate these sentences to produce a short story. The return value for this function is expected to be the story itself and the number of times a specific word target_word is used in the story. The dictionary for story generation, and the sample function call is provided below. 5} 6 7 #required function name and sample function call with the expected return vals out_story, word_ct = write_short story (3,"cat") # n=3, target_word = "cat" 8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The image you provided contains a prompt for writing a Python function called writeshortstory that t... View full answer

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 Programming Questions!