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
2 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]2 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
Question 40 and the next Question 41
TEA [102]

Answer:

there's no photo? but I'm willing to help

8 0
2 years ago
Determine the work input and entropy generation during the compression of steam from 100 kPa to 1 MPa in (a) an adiabatic pump a
Goshia [24]

Answer:

See attachment below

Explanation:

6 0
3 years ago
How does heat conduction differ from convection?
Helga [31]

Explanation:

Conduction:

     Heat transfer in the conduction occurs due to movement of molecule or we can say that due to movement of electrons in the two end of same the body. Generally,  phenomenon of conduction happens in the case of solid . In conduction heat transfer takes places due to direct contact of two bodies.

Convection:

              In convection heat transfer of fluid takes place due to density difference .In simple words we can say that heat transfer occur due to motion of fluid.

7 0
3 years ago
Read 2 more answers
help me please help me please help me please help me please help me please help me please help me please help me please help me
kakasveta [241]

Answer:

With what?

Explanation:

Brainliest?

7 0
3 years ago
Read 2 more answers
Consider fully developed laminar flow in a circular pipe. If the viscosity of the fluid is reduced by half by heating while the
gladu [14]

Answer:

The pressure drop across the pipe also reduces by half of its initial value if the viscosity of the fluid reduces by half of its original value.

Explanation:

For a fully developed laminar flow in a circular pipe, the flowrate (volumetric) is given by the Hagen-Poiseulle's equation.

Q = π(ΔPR⁴/8μL)

where Q = volumetric flowrate

ΔP = Pressure drop across the pipe

μ = fluid viscosity

L = pipe length

If all the other parameters are kept constant, the pressure drop across the circular pipe is directly proportional to the viscosity of the fluid flowing in the pipe

ΔP = μ(8QL/πR⁴)

ΔP = Kμ

K = (8QL/πR⁴) = constant (for this question)

ΔP = Kμ

K = (ΔP/μ)

So, if the viscosity is halved, the new viscosity (μ₁) will be half of the original viscosity (μ).

μ₁ = (μ/2)

The new pressure drop (ΔP₁) is then

ΔP₁ = Kμ₁ = K(μ/2)

Recall,

K = (ΔP/μ)

ΔP₁ = K(μ/2) = (ΔP/μ) × (μ/2) = (ΔP/2)

Hence, the pressure drop across the pipe also reduces by half of its initial value if the viscosity of the fluid reduces by half of its value.

Hope this Helps!!!

4 0
2 years ago
Other questions:
  • According to the decreasing order of toughness. list the following materials (note: the steels are assumed to have no cold work
    6·1 answer
  • Name the important trees of tropical monsoon forest​
    11·1 answer
  • What fuel do rockets use
    9·2 answers
  • Breaks do not overheat true false ?
    6·1 answer
  • a digital multimeter is set to read dc volts on the 4 volt scale the meter leads are connected to a 12 volt battery what will th
    14·2 answers
  • What is the function of engineering
    6·1 answer
  • If the power to a condensing unit has been turned off for an extended period of time, the _________________________ should be en
    12·1 answer
  • An isothermal CSTR with a first order irreversible reaction A â> B (and rA[mol/(ft3*min)] = - 0.5 CA) has a constant flow rat
    13·1 answer
  • There is a black-box system (i.e we do not know the transfer function of the system). When we fed a step input into the system,
    9·1 answer
  • In an RL parallel circuit, VT = 240 V, R = 330 Ω, and XL = 420 Ω. What is the Apparent Power (VA)?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!