Python 3 Modify Sentence Generator Program Case Study Inputs Vocabulary Set Text Files Sta Q37058005

Python 3

Modify the sentence-generator program of Case Study sothat it inputs its vocabulary from a set of text files at startup.The filenames are nouns.txt, verbs. txt, articles.txt, andprepositions.txt.

(HINT: Define a single new function, getWords.This function should expect a filename as an argument. The functionshould open an input file with this name, define a temporary list,read words from the file, and add them to the list. The functionshould then convert the list to a tuple and return this tuple. Callthe function with an actual filename to initialize each of the fourvariables for the vocabulary.)

Case Study: Generating Sentences code:

import random
articles = (“A”,

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.