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
An aircraft component is fabricated from an aluminum alloy that has a plane strain fracture toughness of 40 . For an applied str
erma4kov [3.2K]

Answer:

B. 2.3mm

Explanation:

The correct answer for the given question is B. 2.3mm. Some aircraft are made are fabricated from aluminium which has plane stain fracture toughness. In the given scenario the plane stain toughness is

Ktc = 40 [ MPa \sqrt{(m)} ]

When the Ktc increases the fracture will appear on the aircraft. In this case the maximum crack until the fracture failure is 2.5mm.

8 0
3 years ago
Two plates are separated by a 1/4 in space. The lower plate is stationary; the upper plate moves at 10 ft/s. Oil (viscosity of 2
Montano1993 [528]

Answer:

τ = 0.25 lbf/in²

Explanation:

given that the oil viscosity, μ =  2.415 lb/ft-s

gap between plates = 1/4 inches = 1/4*12 = 1/48 ft

recall from newtons law of viscosity;

shear stress τ = μ du/dy =

  τ = (2.415 lb/ft-s) (10 ft/s)/(1/48) ft

τ = 1159.2 lb/ft-s²

we know that, 1 slug = 32.174 lb

lb = 1/32.174 slug

∴  τ = 1159.2/32.174 slug/ft-s² = 36 slug/ft-s²

τ = 36 slug/ft-s²

multiply both the numerator and denominator by ft, this gives

τ = 36 slug-ft/ft²-s²

τ = 36 lbf/ft² where 1 slug-ft/s² = 1lbf

since 1 ft = 12 inch = 1 ft² = 12² in² = 144 in²

∴  τ = 36/144 lbf /in² = 0.25 lbf/in²

τ = 0.25 lbf/in²

6 0
3 years ago
A household refrigerator that has a power input of 450 W and a COP of 1.5 is to cool five large watermelons, 10 kg each, to 8°C.
Andreyy89

Answer:

6222.22 sec

Explanation:

Given data the power input to the refrigerator is 450 W

The COP of refrigerator is 1.5

Temperature T_1=8^{\circ}C

T_2=28^{\circ}C

mass of watermelon =10 kg

specific heat =4.2 KJ/kg°C

The amount of heat removed from 5 watermelon

Q=mc_pdt=5\times 10\times 4.2\times (28-8)=4200 KJ

We know that COP=\frac{Q_1}{W}

1.5=\frac{Q_1}{450}

Q_1=675 W=0.675 KW

so time required to cool the watermelon is

t=\frac{Q_1}{Q_2}=\frac{4200}{0.675}=6222.22 sec  

4 0
3 years ago
For a copper-silver alloy of composition 25 wt% Ag-75 wt% Cu and at 775C (1425F) do the following: (a) Determine the mass frac
allochka39001 [22]

Answer:

a)

mass fraction of α = 0.796

mass fraction of β = 0.204

b)

mass fraction of primary α (Wα) = 0.734

mass fraction of  eutectic micro-constituents (We) = 0.266

c)

α in eutectic mixture = 0.062

Explanation:

Assumptions:

(i) the  system is in thermal equilibrium with its surroundings

(ii) There are no impurities or other alloying elements present

(a) Determine the mass fractions of α and β phases

From the Cu - Ag phase diagram, Cα = 8.0 wt% Ag, Cβ = 91.2 wt% Ag, and C0 = 25 wt% Ag .Using the lever-rule:

Total mass fraction of α = (Cβ - C0) / (Cβ - Cα) = (91.2 - 25) / (91.2 - 8) = 0.796

Total mass fraction of β = (C0 - Cα) / (Cβ - Cα) = (25 - 8) / (91.2 - 8) = 0.204

(b) Determine the mass fractions of primary α and eutectic microconstituents

Ceutetic = 71.9 wt.%Ag

mass fraction of primary α (Wα) = (Ceutetic - C0) / (Ceutetic - Cα) = (71.9 - 25) / (71.9 - 8) = 0.734

mass fraction of  eutectic micro-constituents (We) = (C0 - Cα) / (Ceutetic - Cα) = (25 - 8) / (71.9 - 8) = 0.266

(c) Determine the mass fraction of eutectic α.

From the eutetic reaction, L  ↔    α + β

Total α = Primary α + α in eutectic mixture

Therefore: α in eutectic mixture = Total α - Primary α = 0.796 - 0.734 = 0.062

5 0
3 years ago
Read 2 more answers
What do auto mechanics do when they take out the spark plugs
ivanzaharov [21]
Check them to see if the cylinder is running rich or lean. This can be determined by looking at the electrodes on the plugs
Hope this helps.
7 0
3 years ago
Other questions:
  • A car accelerates from O to 60. miles per hour in 5.2 seconds. Calculate acceleration in m/s seconds. Calculate acceleration in
    15·1 answer
  • An aquifer has three different formations. Formation A has a thickness of 8.0 m and hydraulic conductivity of 25.0 m/d. Formatio
    9·1 answer
  • Ayden read 84 pages in 2 hours. At that rate, how many pages can he read in 5 hours
    11·2 answers
  • Consider a point in a structural member that is subjected to plane stress. Normal and shear stress magnitudes acting on horizont
    8·1 answer
  • Ben is an aeronautical engineer who helps build rockets. What talent might help ben in his career?
    14·1 answer
  • two cars travel on a straight road from the point. A to point B both cars accelerate to their maximum speed and then continue at
    10·1 answer
  • What does polarity give you information about?
    10·1 answer
  • How long did it take the Niagara power plant to be built
    14·2 answers
  • What is the foundation​
    12·1 answer
  • Which type of work is a textile engineer most likely to do?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!