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
Two wafer sizes are to be compared: a 156-mm wafer with a processable area = 150mm diameter circle and a 312-mm wafer with a pro
Alja [10]

Answer:

a) 100%

b) 300%

c) 301 %

Explanation:

The first wafer has a diameter of 150 mm.

The second wafer has a diameter of 300 mm.

The second wafer has an increase in diameter respect of the first of:

((300 / 150)  - 1) * 100 = 100%

The first wafers has a processable area of:

A1 = π/4 * D1^2

The scond wafer has a processable area of:

A2 = π/4 * D2^2

The seconf wafer has a increase in area respect of the first of:

(A2/A1 * - 1) * 100

((π/4 * D2^2) / (π/4 * D1^2) - 1) * 100

((D2^2) / (D1^2) - 1) * 100

((300^2) / (150^2) - 1) * 100 = 300%

The area of a chip is

Ac = Lc^2

So the chips that can be made from the first wafer are:

C1 = A1 / Ac

C1 = (π/4 * D1^2) / Lc^2

C1 = (π/4 * 150^2) / 10^2 = 176.7

Rounded down to 176

The chips that can be made from the second wafer are:

C2 = A2 / Ac

C2 = (π/4 * D2^2) / Lc^2

C2 = (π/4 * 300^2) / 10^2 = 706.8

Rounded down to 706

The second wafer has an increase of chips that can be made from it respect of the first wafer of:

(C2 / C1 - 1) * 100

(706 / 176 - 1) *100 = 301%

8 0
3 years ago
Some connecting rods have ____ to help lubricate the cylinder wall or piston pin.
Ket [755]

Answer:

some connecting rods have spit holes

4 0
4 years ago
Read 2 more answers
Entor" by
IrinaVladis [17]

Answer:

To generalize your thought about answer. in technology

Explanation:

4 0
3 years ago
(Laminar flow) A fluid flows through two horizontal pipes of equal length which are connected together to form a pipe of length
EastWind [94]

This question is incomplete, the complete question is;

(Laminar flow) A fluid flows through two horizontal pipes of equal length which are connected together to form a pipe of length 2l. The flow is laminar and fully developed. The pressure drop for the first pipe is 1.657 times greater than it is for the second pipe. If the diameter of the first pipe is D, determine the diameter of the second pipe.

D₃ = _____D.

{ the tolerance is +/-3% }

Answer:

the diameter of the second pipe D₃ is 1.13D

Explanation:

Given the data in the question;

Length = 2l

pressure drop in the first pipe is 1.657 times greater than it is for the second pipe.

Now, we know that for Laminar Flow;

V' = πD⁴ΔP / 128μL

where V'₁ = V'₂ and ΔP₁₋₂ = 1.657 ΔP₂₋₃

Hence,

V'₁ = πD⁴ΔP₁₋₂ / 128μL  = V'₃ = πD₃⁴ΔP₂₋₃ / 128μL

so

D₃ = D( ΔP₁₋₂ / ΔP₂₋₃ )^{\frac{1}{4}

we substitute

D₃ = D( 1.657 )^{\frac{1}{4}

D₃ = D( 1.134568 )

D₃ = 1.13D

Therefore, the diameter of the second pipe D₃ is 1.13D

8 0
3 years ago
A receptacle, plug, or any other electrical device whose design limits the ability of an electrician to come in contact with any
o-na [289]

Answer:

Recessed  safe

Explanation:

A recessed, receptacle or plug is one in which the metal interfacing parts have been retracted back in such a way that common contact between a person handling the receptacle or outlet will not ordinarily lead to exposure to electric shock hazard and as such improving the safety of use of such plug, receptacle or electrical device either at home or in industrial setting

A recessed outlet is also more ideal than standard outlets where there are hazards such as potential contact with water.

4 0
3 years ago
Other questions:
  • The council members of a small town have decided that an earth levee should be rebuilt and strengthen to protect against future
    10·1 answer
  • Steam at 150 bars and 600°C passes through process equipment and emerges at 100 bars and 700°C. There is no flow of work into or
    8·1 answer
  • Determine whether or not each of the following four transaction execution histories is serializable. If a history is serializabl
    7·1 answer
  • Assume that a chocolate bar consists of n squares ar- ranged in a rectangular pattern. The entire bar, or any smaller rectangula
    8·1 answer
  • Chaplets are used to support a sand core inside a sand mold cavity. The design of the
    13·1 answer
  • A cubic transmission casing whose side length is 25cm receives an input from the engine at a rate of 350 hp. If the vehicle's ve
    5·1 answer
  • Harlin is designing a new car engine that does not create pollution. Which technological design factor is probably the most
    8·1 answer
  • A 12 kg hockey puck is traveling at a velocity of 15 m/s. What is the momentum?
    7·1 answer
  • Define in detail Technology and Evolution in the context of your prior Knowledge?​
    7·1 answer
  • The source term will affect all algebraic equations.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!