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
Crank
3 years ago
10

Write a method called letterCount that takes two String arguments, one containing some text and the other containing a single le

tter. This method should then compute and return the count of all of the occurrences of that letter in the given text.

Engineering
1 answer:
jenyasd209 [6]3 years ago
4 0

Answer:

I am writing a Python program.  Here is the function letterCount. This function takes two string arguments text and letter and return count of all occurrences of a letter in the text.

def letterCount(text, letter):  

 count = 0  # to count occurrences of letter in the text string

 for char in text:  # loop moves through each character in the text

   if letter == char: # if given letter matches with the value in char

     count += 1  # keeps counting occurrence of a letter in text

 return count # returns how many times a letter occurred in text

   

Explanation:

In order to see if this function works you can check by calling this function and passing a text and a letter as following:

print(letterCount('apples are tasty','a'))

Output:

3

Now lets see how this function works using the above text and letter values.

text = apples are tasty

letter = a

So the function has to compute the occurrences of 'a' in the given text 'apples are tasty'.

The loop has a variable char that moves through each character given in the text (from a of apples to y of tasty) so it is used as an index variable.

char checks each character of the text string for the occurrence of letter a.

The if condition checks if the char is positioned at a character which matches the given letter i.e. a. If it is true e.g if char is at character a of apple so the if condition evaluates to true.

When the if condition evaluates to true this means one occurrence is found and this count variable counts this occurrence. So count increments every time the occurrence of letter a is found in apples are tasty text.

The loop breaks when every character in text is traversed and finally the count variable returns all of the occurrences of that letter (a) in the given text (apples are tasty). As a occurs 3 times in text so 3 is returned in output.

The screen shot of program along with output is attached.

You might be interested in
A gas tank is known to have a thickness of 0.5 inches and an internal pressure of 2.2 ksi. Assuming that the maximum allowable s
sergiy2304 [10]

Answer:

D_o=11.9inch

Explanation:

From the question we are told that:

Thickness T=0.5

Internal PressureP=2.2Ksi

Shear stress \sigma=12ksi

Elastic modulus \gamma= 35000

Generally the equation for shear stress is mathematically given by

 \sigma=\frac{P*r_1}{2*t}

Where

r_i=internal Radius

Therefore

 12=\frac{2.2*r_1}{2*0.5}

 r_i=5.45

Generally

 r_o=r_1+t

 r_o=5.45+0.5

 r_o=5.95

Generally the equation for outer diameter is mathematically given by

 D_o=2r_o

 D_o=11.9inch

Therefore

Assuming that the thin cylinder is subjected to integral Pressure

Outer Diameter is

 D_o=11.9inch

7 0
3 years ago
AVH
BigorU [14]

Answer: preventive maintenance

Explanation:

3 0
3 years ago
Substances A and B have retention times of 16.63 and 17.63 min, respectively, on a 30 cm column. An unretained species passes th
Svet_ta [14]

Answer:

The time required to elute the two species is 53.3727 min

Explanation:

Given data:

tA = retention time of A=16.63 min

tB=retention time of B=17.63 min

WA=peak of A=1.11 min

WB=peak of B=1.21 min

The mathematical expression for the resolution is:

Re_{s} =\frac{2(t_{B}-t_{A})}{W_{A}+W_{B} } =\frac{2*(17.63-16.63)}{1.11+1.21} =0.8621

The mathematical expression for the time to elute the two species is:

\frac{t_{2}}{t_{1}} =(\frac{Re_{B} }{Re_{s} } )^{2}

Here

ReB = 1.5

t_{2} =t_{1} *(\frac{Re_{B} }{Re_{s} } )^{2} =17.63*(\frac{1.5}{0.8621} )^{2} =53.3727min

6 0
3 years ago
A section of highway has a free-flow speed of 55 mph and a capacity of 3300 veh/hr. In a given hour, 2100 vehicles were counted
alexira [117]

Answer:

Space mean speed = 44 mi/h

Explanation:

Using Greenshield's linear model

q = Uf ( D - D^{2}/Dj )

qcap = capacity flow that gives Dcap

Dcap = Dj/2

qcap = Uf. Dj/4

Where

U = space mean speed

Uf =  free flow speed

D = density

Dj = jam density

now,

Dj = 4 × 3300/55

    = 240v/h

q = Dj ( U - U^{2}/Uf)

2100 = 240 ( U - U^{2}/55)

Solve for U

U = 44m/h

5 0
3 years ago
Where does Henrietta think William might be?
umka2103 [35]

Answer:

The cemetery

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • An important ethical concern for behavior analysts involves special cautions in interactions with a client in any capacity outsi
    5·1 answer
  • Identify the advantages of using 6 tube passes instead of just 2 of the same diameter in shell-and-tube heat exchanger.What are
    10·1 answer
  • A fatigue test is performed on 69 rotating specimens made of 5160H steel. The measured number of cycles to failure (L in kcycles
    6·1 answer
  • Which of these is least likely a step in replacing a failed compressor?
    12·2 answers
  • What are the four basic parts of process plan
    11·1 answer
  • A light bulb is switched on and within a few minutes its temperature becomes constant. Is it at equilibrium or steady state.
    7·1 answer
  • A masonry facade consisting of 3,800 square feet is to be constructed for a building. The total cost per worker hour is estimate
    6·1 answer
  • What is 94*738^389428394
    8·1 answer
  • Technician A says when you push the horn button, electromagnetism moves an iron bar inside the horn, which opens and closes cont
    5·2 answers
  • What is the moment that the wrench puts on the bolt?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!