subject

Modify the sentence-generator program of Case Study so that it inputs its vocabulary from a set of text files at startup. The filenames are nouns. txt, verbs. txt, articles. txt, and prepositions. txt. (Hint: Define a single new function, getWords. This function should expect a filename as an argument. The function should open an input file with this name, define a temporary list, read words from the file, and add them to the list. The function should then convert the list to a tuple and return this tuple. Call the function with an actual filename to ini- tialize each of the four variables for the vocabulary.)Case Study: Generating Sentences code:import randomarticles = ("A", "THE")nouns = ("BOY", "GIRL", "BAT", "BALL")verbs = ("HIT", "SAW", "LIKED")prepositions = ("WITH", "BY")def sentence():return nounPhrase() + " " + verbPhrase()def nounPhrase():return random. choice(articles) + " " + random. choice(nouns)def verbPhrase():return random. choice(verbs) + " " + nounPhrase() + " " + \prepositionalPhrase()def prepositionalPhrase():return random. choice(prepositions) + " " + nounPhrase()def main():number = int(input("Enter the number of sentences: "))for count in range(number):print(sentence())if __name__ == "__main__":main()

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:20
In what kind of attack can attackers make use of millions of computers under their control in an attack against a single server or network availability confidentiality integrity identity automated attack software? those who wrongfully disclose individually identifiable health information can be fined up to what amount per calendar year? single most expensive malicious attack hipaa what are script kiddies? advanced persistent threat security manager security engineer what level of security access should a computer user have to do their job what process describes using technology as a basis for controlling the access and usage of sensitive data? cybercriminal
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
You have been supporting csm tech publishing's windows server 2016 server network for over a year. the office has two windows server 2016 servers running active directory and a number of other roles. management has informed you that a small sales office is opening in the same building three floors up. the sales manager wants to install a sales application on a server located in the sales office. this server will have limited physical security because there's no special room dedicated for it, which means it will be accessible to non-it personnel and visitors. you're considering installing windows server 2016 server core on the new server because accessing its console regularly probably won't be necessary, and this server will be managed from one of the other csm tech publishing servers. what are the benefits and drawbacks of using server core for this branch office? what are some things you should do to set up this server management environment?
Answers: 1
question
Computers and Technology, 23.06.2019 18:30
The computers in the sales department did not have enough data storage capacity to contain all the information the department needed to store, and it was taking a long time for team members to access the data they needed. to fix the problem, the technician installed new, larger hard drives on all the computers.
Answers: 1
question
Computers and Technology, 24.06.2019 10:00
What did i do wrong with this const discord = require('discord.js'); var bot = new discord.client(); const token = 'ntm3mjcxmtu1mjg3ote2ntq2.dyogew.dpfiwfpuifzuzvifop-csuxasnm' const prefix = "! " bot.registry.registergroup('simple', 'simple'); bot.registry.registerdefaults(); bot.registry. + '/commands'); bot.on('message', message => { if(message.content == 'hi! ') { message.channel.send ('@everyone sup, how is @everyone day going'); } if(message.content == 'h3lp') { message.channel.send ('dose not have any commands yet'); } bot.on('ready', function() { console.log("ready") }); bot.login(token);
Answers: 1
You know the right answer?
Modify the sentence-generator program of Case Study so that it inputs its vocabulary from a set of t...
Questions
question
Arts, 08.04.2020 18:46
question
Mathematics, 08.04.2020 18:46
Questions on the website: 13722367