Given the following script
import random
articles = ("A", "THE")
nouns = ("BOY", "GIRL", "BAT", "BALL")
verbs =("HIT", "SAW", "LIKED")
prepositions =("WITH", "BY")
def sentence():
"""Builds and returns a sentence"""
return nounPhrase() + ""+ verbPhrase()
def nounPhrase():
"""Builds and return a noun phrase"""
return random.choice(articles) + ""+ random.choice(nouns)
def verbPhrase():
"""Builds and return a verb phrase"""
return random.choice(verbs) + "" + nounPhrase + prepositionalPhrase()
defprepositionPhrase():
"""Builds and returns a prepositional phrase"""
Return random.choice(prepositions) + "" + nounPhrase()
def main():
"""Let user input number of sentences to be generated"""
number = int(input("Enter the number of sentences: "))
for count in range(number):
print(sentence())
main() #call to main
Modify the script so you can add adjectives to write random sentences such as THE BOY HIT THE RED BALL., or the BALL HIT THE RED BOY. Add additional words of your own. Finally ask the user how many sentences are to generated.
Using python