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
What is the instantaneous center of zero velocity? List two approaches for determining the is the instantaneous center of zero v
Lera25 [3.4K]

Explanation:

Instantaneous center:

   It is the center about a body moves in planer motion.The velocity of Instantaneous center is zero and Instantaneous center can be lie out side or inside the body.About this center every particle of a body rotates.

From the diagram

Where these two lines will cut then it will the I-Center.Point A and B is moving perpendicular to the point I.

If we take three link link1,link2 and link3 then I center of these three link will be in one straight line It means that they will be co-linear.

I_{12},I_{23},I_{31} all\ are\ co-linear.

5 0
3 years ago
An 1,840 W toaster, a 1,420 W electric frying pan, and a 70 W lamp are plugged into the same outlet in a 15 A, 120 V circuit. (T
Viktor [21]

Answer:

A)

Current drawn by toaster = 15.33 A

Current drawn by electric frying pan = 11.83 A

Current drawn by lamp = 0.58 A

B)

The fuse will definitely blow up since the current drawn by three devices (27.74 A) is way higher than 15 A fuse rating.

Explanation:

There are three devices plugged into the same outlet.

Toaster = 1840 W

Electric frying pan = 1420 W

Lamp = 70 W

Since the three devices are connected in parallel therefore, the voltage across them will be same but the current drawn by each will be different.

A) What current is drawn by each device?

The current flowing through the device is given by

I = P/V

Where P is the power and V is the voltage.

Current drawn by toaster:

I = 1840/120

I = 15.33 A

Current drawn by electric frying pan:

I = 1420/120

I = 11.83 A

Current drawn by lamp:

I = 70/120

I = 0.58 A

B) Will this combination blow the 15-A fuse?

The total current drawn by all three devices is

Total current = 15.33 + 11.83 + 0.58

Total current = 27.74 A

Therefore, the fuse will definitely blow up since the current drawn by three devices (27.74 A) is way higher than 15 A fuse rating.

5 0
3 years ago
An L2 steel strap having a thickness of 0.125 in. and a width of 2 in. is bent into a circular arc of radius 600 in. Determine t
lesya692 [45]

Answer:

the maximum bending stress in the strap is 3.02 ksi

Explanation:

Given the data in the question;

steel strap thickness = 0.125 in

width = 2 in

circular arc radius = 600 in

we know that, standard value of modulus of elasticity of L2 steel is; E = 29 × 10³ ksi;

Now, using simple theory of bending

1/p = M/EI

solve for M

Mp = EI

M = EI / p ----- let this be equation 1

The maximum bending stress in the strap is;

σ = Mc / I -------let this be equation 2

substitute equation 1 into 2

σ = ( EI / p)c / I

σ = ( c/p )E

so we substitute in our values

σ = ( (0.125/2) / 600 )29 × 10³

σ = 0.00010416666 × 29 × 10³

σ = 3.02 ksi

Therefore, the maximum bending stress in the strap is 3.02 ksi

3 0
3 years ago
When your hands are on home row, they are resting on the____.
MArishka [77]

Answer:

to which four fingers of each hand return as a base, on a QWERTY keyboard being A, S, D, and F for the left hand and J, K, L, and the semicolon for the right

Explanation:

4 0
3 years ago
Read 2 more answers
Consider three branch prediction schemes: predict not taken, predict taken, and dynamic prediction. Assume that they all have ze
SOVA2 [1]

Answer:

Check the explanation

Explanation:

1. When a branch is taken with 5% frequency, the branch prediction scheme is "predict taken" because the process has to begin fetching and then execute at the target address.

2. When a branch is taken with 95% frequency, the branch prediction scheme is "predict not taken" because the branch outcome is definitely known.

3. When a branch is taken with 70% frequency, the prediction scheme is "dynamic prediction" the branch prediction can dynamically change during the program execution.

3 0
3 years ago
Other questions:
  • In a tensile test on a steel specimen, true strain is 0.171 at a stress of 263.8 MPa. When true stress is 346.2 MPa, true strain
    7·1 answer
  • What is the difference between filler and electrode in Welding? Can a filler be an electrode? Can an electrode be a filler? Why?
    6·1 answer
  • An aggregate blend is composed of 65% coarse aggregate by weight (Sp. Cr. 2.635), 36% fine aggregate (Sp. Gr. 2.710), and 5% fil
    5·1 answer
  • A railroad runs form city A to city B, a distance of 800km, through mountainous terrain. The present one-way travel time (includ
    13·1 answer
  • Which of the following describes a product concept?
    15·1 answer
  • Help me is it a b c or d?
    14·1 answer
  • A lightbulb has a fixed negative and positive connector. You cannot swap positive and negative sides of a lightbulb in a circuit
    9·2 answers
  • In the following scenario, what could the engineers have done to keep the bridge from collapsing?
    8·1 answer
  • From the top of a vertical cliff 80m high, the angles of depression of 2 buoys lying due west of the cliff are 23° and 15° respe
    13·1 answer
  • All of these are true about a magnesium part EXCEPT that it:
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!