Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 '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
Step: 1
The image you provided contains a prompt for writing a Python function called writeshortstory that t...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started