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]
1 year 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]1 year ago
3 0

Answer:

1

Explanation:

You might be interested in
Which step in the engineering design phase is requiring concussion prevention from blows up to 40 mph an example of?
Charra [1.4K]

Answer:

Target your customers

Explanation:

took the test :)

6 0
3 years ago
Engineered lumber should not be used for
Dimas [21]

Answer:

Composite panel garage doors

Explanation:

8 0
2 years ago
How can I solve 23.5 million Nona meters to millimeters using no calculator because I have to show my work
katrin2010 [14]

Express it in standard form and apply the basic indices laws to simplify

6 0
3 years ago
Read 2 more answers
A number 12 copper wire has a diameter of 2.053 mm. Calculate the resistance of a 37.0 m long piece of such wire.
Alinara [238K]

Answer:

R=1923Ω

Explanation:

Resistivity(R) of copper wire at 20 degrees Celsius is 1.72x10^-8Ωm.

Coil length(L) of the wire=37.0m

Cross-sectional area of the conductor or wire (A) = πr^2

A= π * (2.053/1000)/2=3.31*10^-6

To calculate for the resistance (R):

R=ρ*L/A

R=(1.72*10^8)*(37.0)/(3.31*10^-6)

R=1922.65Ω

Approximately, R=1923Ω

5 0
3 years ago
To find the quotient of 8 divided by 1/3, multiply 8 by?
iVinArrow [24]

Answer: 8.33333333 or 6.1989778

Explanation:

8 0
2 years ago
Other questions:
  • In a fluid power system, if energy is not transferred to work, what form does it take?
    6·1 answer
  • A 25 lb sacrificial Mg anode is attached to the steel hull of a container ship. If the anode completely corrodes within 3 months
    10·1 answer
  • The typical Canadian worker is able to produce 100 board feet (a unit of measure) of lumber or 1000 light bulbs per year. The wo
    12·1 answer
  • Please please help please with this this is the link for the story PLEASE PLEASE HELP PLEASE PLEASE help please
    7·1 answer
  • Can U lose a rank in Brainly by using too many points?
    6·1 answer
  • A tiger cub has a pattern of stripes on it for that is similar to that of his parents where are the instructions stored that pro
    8·1 answer
  • 19. A circuit contains four 100 S2 resistors connected in series. If you test the circuit with a digital VOM,
    9·1 answer
  • PDC Bank is working on creating an AI application that enables customers to send SMS to the AI application to allow banking acti
    9·1 answer
  • As you have learned, not all motor oils are the same. What are two things that make them different?.
    11·1 answer
  • The metric ruler is typically divided into
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!