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 furnace uses preheated air to improve its fuel efficiency. Determine the adiabatic flame temperature when the furnance is oper
balu736 [363]

Answer:

2543 k

Explanation:

This problem can be resolved by applying the first law of thermodynamics

<u>Determine the adiabatic flame temperature</u> when the furnace is operating at a mass air-fuel ratio of 16 for air preheated to 600 K

attached below is a detailed solution

cp = 1200

8 0
3 years ago
Write a program to control the operation of the RED/GREEN/BLUE LED (LED2) as follows: 1. If no button is pressed, the LED should
aalyn [17]

Answer:

See explaination

Explanation:

int RED=10; int BLUE=11; int GREEN=12; int BUTTON1=8; int BUTTON2=9; void setup() { pinMode(RED, OUTPUT); pinMode(BLUE, OUTPUT); pinMode(GREEN, OUTPUT); pinMode(BUTTON1, INPUT); pinMode(BUTTON2, OUTPUT); } void loop() { int BTN1_STATE=digitalRead(BUTTON1); int BTN2_STATE=digitalRead(BUTTON2); if(BTN1_STATE==HIGH) { digitalWrite(BLUE, HIGH); delay(1000); // Wait for 1 second digitalWrite(BLUE, LOW); } if(BTN2_STATE==HIGH) { digitalWrite(RED, HIGH); delay(4000); // Wait for 4 seconds digitalWrite(RED, LOW); } if(BTN1_STATE==HIGH && BTN2_STATE==HIGH) { digitalWrite(GREEN, HIGH); delay(2000); // Wait for 2 second digitalWrite(GREEN, LOW); } }

4 0
3 years ago
A 11-cm-diameter horizontal jet of water with a velocity of 40 m/s relative to the ground strikes a flat plate that is moving in
Reika [66]

Answer:

F = 8552.7N

Explanation:

We need first our values, that are,

V_{jet} = 40m/s\\V_{Plate} = 10m/s \\D = 11cm

We start to calculate the relative velocity, that is,

V_r = V_{jet}-V_{plate}\\V_r = (40)-(10)\\V_r = 30m/s

With the relative velocity we can calculate the mass flow rate, given by,

\dot{m}_r = \rho A V_r

\dot{m}_r = (1000)(30) \frac{\pi (0.11)^2}{4}

\dot{m}_r = 285.09kg/s

We need to define the Force in the direction of the flow,

\sum\vec{F} = \sum_{out} \beta\dot{m}\vec{V} - \sum_{in} \beta\dot{m} \vec{V}\\

F = \dot{m}V_r

F = (285.09Kg/s)(30)

F = 8552.7N

8 0
3 years ago
The entire system of components that produces power and transmits it to the road is called the vehicle's _____.
IrinaK [193]

Answer:

Powertrain

Explanation:

6 0
3 years ago
2. When manipulating your pedals, you should use your
astra-53 [7]

Answer:

D. left foot for the accelerator and your right foot for the brake.

* Hopefully this helps:) mark me the brainliest:)!!

7 0
3 years ago
Read 2 more answers
Other questions:
  • Air is compressed adiabatically from p1 1 bar, T1 300 K to p2 15 bar, v2 0.1227 m3 /kg. The air is then cooled at constant volum
    13·1 answer
  • If a building is too humid, what harmful substance may be stored there?
    13·2 answers
  • Consider five wireless stations A,B,C,D,E. Station
    5·2 answers
  • One of the best ways to find a vacuum leak on a speed-density fuel-injection system is to read the intake air controller (LAC) c
    12·2 answers
  • A plane wall of thickness 2L = 40 mm and thermal conductivity k = 5 W/m K experiences uniform volumetric heat generation at a ra
    15·1 answer
  • Phân tích phương pháp gia công plasma
    10·1 answer
  • In a wire, when elongation is 4 cm energy stored is E. if it is stretched by 4 cm, then what amount of elastic potential energy
    15·2 answers
  • Although many countries have issues with soil erosion due to deforestation, some of the most serious effects are seen
    8·1 answer
  • Which of the following devices is a simple machine?
    11·2 answers
  • In the situation shown below, what would the Moon look like from Earth? Sun, Earth and Moon Four Moon Views A. View A B. View B
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!