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
function summedValue = SummationWithLoop(userNum) % Summation of all values from 1 to userNum summedValue = 0; i = 1; % Write a
Alexeev081 [22]

Answer:

function summedValue = SummationWithLoop(userNum)

% Summation of all values from 1 to userNum

  summedValue = 0;

  i = 0;

  % use a while loop that assigns summedValue with the

  % sum of all values from 1 to userNum

  while(i <= userNum)

      summedValue = summedValue + i;

      i = i + 1;

  end

end

8 0
3 years ago
Suppose you have two arrays: Arr1 and Arr2. Arr1 will be sorted values. For each element v in Arr2, you need to write a pseudo c
brilliants [131]

Answer:

The algorithm is as follows:

1. Declare Arr1 and Arr2

2. Get Input for Arr1 and Arr2

3. Initialize count to 0

4. For i in Arr2

4.1 For j in Arr1:

4.1.1 If i > j Then

4.1.1.1 count = count + 1

4.2 End j loop

4.3 Print count

4.4 count = 0

4.5 End i loop

5. End

Explanation:

This declares both arrays

1. Declare Arr1 and Arr2

This gets input for both arrays

2. Get Input for Arr1 and Arr2

This initializes count to 0

3. Initialize count to 0

This iterates through Arr2

4. For i in Arr2

This iterates through Arr1 (An inner loop)

4.1 For j in Arr1:

This checks if current element is greater than current element in Arr1

4.1.1 If i > j Then

If yes, count is incremented by 1

4.1.1.1 count = count + 1

This ends the inner loop

4.2 End j loop

Print count and set count to 0

<em>4.3 Print count</em>

<em>4.4 count = 0</em>

End the outer loop

4.5 End i loop

End the algorithm

5. End

6 0
3 years ago
A standard penetration test has been conducted on a coarse sand at a depth of 16 ft below the ground surface. The blow counts ob
scoray [572]

Solution :

Given :

The number of blows is given as :

0 - 6 inch = 4 blows

6 - 12 inch = 6 blows

12 - 18 inch = 6 blows

The vertical effective stress $=1500 \ lb/ft^2$

                                              $= 71.82 \ kN/m^2$

                                             $ \sim 72 \ kN/m^2 $

Now,

$N_1=N_0 \left(\frac{350}{\bar{\sigma}+70} \right)$

$N_1 = $ corrected N - value of overburden

$\bar{\sigma}=$ effective stress at level of test

0 - 6 inch, $N_1=4 \left(\frac{350}{72+70} \right)$

                      = 9.86

6 - 12 inch, $N_1=6 \left(\frac{350}{72+70} \right) $

                        = 14.8

12 - 18 inch, $N_1=6 \left(\frac{350}{72+70} \right) $

                         = 14.8

$N_{avg}=\frac{9.86+14.8+14.8}{3}$

       = 13.14

       = 13

8 0
3 years ago
A large plate is fabricated from a steel alloy that has a plane strain fracture toughness of 55 MPa √m (50 ksi √in.). If, during
astra-53 [7]

Answer:

0.024 m = 24.07 mm

Explanation:

1) Notation

\sigma_c = tensile stress = 200 Mpa

K = plane strain fracture toughness= 55 Mpa\sqrt{m}

\lambda= length of a surface crack (Variable of interest)

2) Definition and Formulas

The Tensile strength is the ability of a material to withstand a pulling force. It is customarily measured in units (F/A), like the pressure. Is an important concept in engineering, especially in the fields of materials and structural engineering.

By definition we have the following formula for the tensile stress:

\sigma_c=\frac{K}{Y\sqrt{\pi\lambda}}   (1)

We are interested on the minimum length of a surface that will lead to a fracture, so we need to solve for \lambda

Multiplying both sides of equation (1) by Y\sqrt{\pi\lambda}

\sigma_c Y\sqrt{\pi\lambda}=K   (2)

Sequaring both sides of equation (2):

(\sigma_c Y\sqrt{\pi\lambda})^2=(K)^2  

\sigma^2_c Y^2 \pi\lambda=K^2   (3)

Dividing both sides by \sigma^2_c Y^2 \pi we got:

\lambda=\frac{1}{\pi}[\frac{K}{Y\sigma_c}]^2   (4)

Replacing the values into equation (4) we got:

\lambda=\frac{1}{\pi}[\frac{55 Mpa\sqrt{m}}{1.0(200Mpa)}]^2 =0.02407m

3) Final solution

So the minimum length of a surface crack that will lead to fracture, would be 24.07 mm or more.

7 0
4 years ago
In your first job with a large U.S based steel company, you have been assigned to a team tasked with developing a new low carbon
nignag [31]

Answer:

Option A

Explanation:

3 0
4 years ago
Read 2 more answers
Other questions:
  • Consider two water tanks filled with water. The first tank is 8 m high and is stationary, while the second tank is 2 m high and
    12·2 answers
  • Determine the average and rms values for the function, y(t)=25+10sino it over the time periods (a) 0 to 0.1 sec and (b) 0 to 1/3
    9·1 answer
  • Python lists are commonly used to store data types. Lists are a collection of information typically called a container. Think of
    5·1 answer
  • How many steps are there in the problem-solving process?
    9·2 answers
  • Excessive looseness in steering and suspension components can cause _____
    13·1 answer
  • Bob would like to run his house off the grid, therefore he needs to find out how many solar panels and batteries he needs to buy
    12·1 answer
  • Who invented engineering first?​
    12·1 answer
  • Why is California a good place for engineers to build suspension bridges?
    12·1 answer
  • What is the placement of a lock out device on an energy isolating device?.
    12·1 answer
  • which of the following is not a general education elective area? group of answer choices humanities/fine arts social/behavioral
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!