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
a vertical cylindrical container is being cooled in ambient air at 25 °C with no air circulation. if the initial temperature of
Sloan [31]

Answer:

the surface heat-transfer coefficient due to natural convection during the initial cooling period.  = 4.93 w/m²k

Explanation:

check attachement for answer explanation

7 0
3 years ago
Read 2 more answers
How wold you classify the earliest examples of S.T.E.M discoveries provided in this lesson?
Gnoma [55]

Answer:

the answer is C

Explanation:

8 0
3 years ago
Which of the following placards allows a driver to park in a handicapped parking space.
malfutka [58]

All of the above ......
4 0
3 years ago
Read 2 more answers
Eutectic product in Fe-C system is called A. Pearlite B. Bainite C. Ledeburite D. Spheroidite
zimovet [89]

Answer:

Eutectic product in Fe-C system is called Ledeburite-C.

6 0
3 years ago
Identify the right components for gsm architecture that consists of the hardware or physical equipment such as digital signal pr
sergiy2304 [10]

The right components for gsm architecture that consists of the hardware or physical equipment such as digital signal processors, radio transceiver, display, battery, case and sim card is the Mobile station.

<h3>What are the 4 main components?</h3>

In GSM, a cell station includes 4 fundamental additives: Mobile termination (MT) - gives not unusualplace features consisting of: radio transmission and handover, speech encoding and decoding, blunders detection and correction, signaling and get right of entry to to the SIM. The IMEI code is connected to the MT.

Under the GSM framework, a cell tele cell smartphone is called a Mobile Station and is partitioned into  wonderful additives: the Subscriber Identity Module (SIM) and the Mobile Equipment (ME).

Read more about the mobile station:

brainly.com/question/917245

#SPJ4

6 0
2 years ago
Other questions:
  • A 400-m^3 storage tank is being constructed to hold LNG, liquefied natural gas, which may be assumed to be essentially pure meth
    8·1 answer
  • Exceeding critical mach may result in the onset of compressibility effects such as:______.
    6·1 answer
  • HELP<br><br><br>the overall width of a part is dimensioned as 3.00 ± 0.02. what is the tolerance
    14·2 answers
  • To test the effects of a new fertilizer, 100 plots were divided in half. Fertilizer A is randomly applied to one half, and B to
    13·2 answers
  • What are the benefits of using the engineering design process
    7·1 answer
  • The convection heat transfer coefficient for a clothed person standing in moving air is expressed as h 5 14.8V0.69 for 0.15 , V
    6·2 answers
  • George is replacing a burned out resistor in a circuit board. The board has a 10, a 20, and a 40 on resistor, all in parallel. W
    5·1 answer
  • The hydrofoil boat has an A-36 steel propeller shaft that is 100 ft long. It is connected to an in-line diesel engine that deliv
    8·1 answer
  • Who is the strongest avenger i say hulk but who knows at this point
    7·2 answers
  • A type of adjustable square that can be used to set, test, and transfer angles is called a
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!