1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
xxMikexx [17]
2 years ago
7

Modify the sentence-generator program so that it inputs its vocabulary from a set of text files at startup. The filenames are no

uns.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 initialize each of the four variables for the vocabulary.)

The code below
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 returns a noun phrase."""
return random.choice(articles) + " " + random.choice(nouns)

def verbPhrase():
"""Builds and returns a verb phrase."""
return random.choice(verbs) + " " + nounPhrase() + " " + \
prepositionalPhrase()

def prepositionalPhrase():
"""Builds and returns a prepositional phrase."""
return random.choice(prepositions) + " " + nounPhrase()

def main():
"""Allows the user to input the number of sentences
to generate."""
number = int(input("Enter the number of sentences: "))
for count in range(number):
print(sentence())

# The entry point for program execution
if __name__ == "__main__":
main()
Engineering
1 answer:
OlgaM077 [116]2 years ago
3 0

Answer:

1

Explanation:

You might be interested in
Which term refers to the impurities found during the welding process ?
Aleks04 [339]

Answer:

idk

Explanation:

idk

6 0
4 years ago
An insulated piston–cylinder device initially contains 1 m3 of air at 120 kPa and 17°C. Air is now heated for 15 min by a 200-W
irakobra [83]

Answer:

∆S1 = 0.5166kJ/K

∆S2 = 0.51826kJ/K

Explanation:

Check attachment for solution

4 0
3 years ago
Which of the following describes beta testing?
Sergio039 [100]

Answer:

What is Beta Testing? Beta testing is an opportunity for real users to use a product in a production environment to uncover any bugs or issues before a general release. Beta testing is the final round of testing before releasing a product to a wide audience.

3 0
3 years ago
Jack has been concerned about the rapidly changing green regulations in his state and his ability as a mechanical engineer to ke
uysha [10]

Answer:

Option A, B and D

Explanation:

Jack can easily convince boss if he focus around two major aspects of the company

a) Revenue enhancement - Jack must outline the benefits of his research that can be used to improvise customer offerings and  hence can be further used to devise more energy-efficient options to customer

b) Reduction in mistakes - Issues such as poor implementation can be avoided with better approach and understanding.

Hence, option A, B and D are correct

3 0
3 years ago
Which of the following statements are true of computer hardware engineers?
9966 [12]

Answer:

you never mentioned the options

3 0
4 years ago
Other questions:
  • 1- Design a brute-force algorithm for solving the problem below (provide pseudocode): You have a large container with storage si
    6·1 answer
  • A series circuit consists of a 0.440-H inductor, a 380.0-Ω resistor, a 5.70-μF capacitor, and an ac voltage source of amplitude
    10·1 answer
  • # line 1 age = int(input("Enter your age: ")) # line 3 print("Invalid input") If we want the computer to display "Invalid input"
    11·1 answer
  • A fire nozzle is coupled to the end of a hose with inside diameter D = 77 mm. The nozzle is smoothly contoured and its outlet di
    7·1 answer
  • Differentiate between pulser switch and data switch
    8·1 answer
  • Plis 3 conclusiones de este video
    15·1 answer
  • A pinion and gear pair is used to transmit a power of 5000 W. The teeth numbers of pinion
    8·1 answer
  • Stucco will shrink as it hardens and cures.<br> A. true<br> B. false
    11·1 answer
  • Someone help me to do this?
    10·1 answer
  • Identify the right components for gsm architecture that consists of the hardware or physical equipment such as digital signal pr
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!