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
Why is it reasonable to say that no system is 100% efficient?​
Virty [35]

Generally, frictional losses are more predominant for the machines being not 100% efficient. This friction leads to the loss of energy in the form of heat, into the surroundings. Some of the supplied energy may be utilised to change the entropy (measure of randomness of the particles) of the system.

5 0
3 years ago
Why is it important to cut all the way through an electrical wire on the first try?
lbvjy [14]

Answer:

I always thought it was so that the older wire could not have a problem and have another electrician must come back and fix it.

Explanation:

6 0
3 years ago
A triangular plate with a base 5 ft and altitude 3 ft is submerged vertically in water. If the base is in the surface of water,
Scorpion4ik [409]

Answer:

Hydrostatic force = 41168 N

Explanation:

Complete question

A triangular plate with a base 5 ft and altitude 3 ft is submerged vertically in water  so that the top is 4 ft below the surface. If the base is in the surface of water, find the force against onr side of the plate. Express the hydrostatic force against one side of the plate as an integral and evaluate it. (Recall that the weight density of water is 62.5 lb/ft3.)

Let "x" be the side length submerged in water.

Then

w(x)/base = (4+3-x)/altitude

w(x)/5 = (4+3-x)/3

w(x) = 5* (7-x)/3

Hydrostatic force = 62.5 integration of  x * 4 * (10-x)/3 with limits from 4 to 7

HF = integration of 40x - 4x^2/3

HF = 20x^2 - 4x^3/9 with limit 4 to 7

HF = (20*7^2 - 4*7^(3/9))- (20*4^2 - 4*4^(3/9))

HF = 658.69 N *62.5 = 41168 N

4 0
2 years ago
Air-conditioners consume a significant amount of electrical energy in buildings. Split air conditioner is a unitary system where
nydimaria [60]

Answer:

Evaporator,Compressor,Condensor ,Expanding valve

Explanation:

Split air conditioning :

  Split air conditioning means that, condensor unit or some time called outdoor unit is split from evaporator.It means that evaporator and condensor are placed at some distance.

The four component of split air conditioning system are as follows

1.Evaporator

 It absorb heat from room and produces the cooling effect.

2.Compressor

 It compresses the refrigerant which exits from evaporator.

3.Condensor

 It rejects the heat and cool the evaporator.

4.Expanding valve

  It allows to refrigerant to cool up to evaporator pressure.

6 0
3 years ago
Aaron needs to create a building design for a restaurant with colors that depict excitement and vibrancy. Which color can Aaron
zloy xaker [14]

Answer:

I'm no engineer, but blue and purple are cool colors and white is every color so I'd go with orange

7 0
2 years ago
Read 2 more answers
Other questions:
  • At a high school science fair, Connor won first place for his replica of the Golden Gate Bridge. Connor liked the project so muc
    5·1 answer
  • A manufacturer makes integrated circuits that each have a resistance layer with a target thickness of 200 units. A circuit won't
    5·1 answer
  • A small truck is to be driven down a 4% grade at 70 mi/h. The coefficient of road adhesion is 0.95, and it is known that the bra
    7·1 answer
  • Nitrate salts (NO3-), when heated, can produce nitrites (NO2-) plus oxygen (O2). A sample of potassium nitrate is heated, and th
    9·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
  • Extra Credit: The Linc (parking lot and stadium)In celebration of the upcoming Super Bowl, for a maximum 10 points of extra cred
    7·1 answer
  • We need to design a logic circuit for interchanging two logic signals. The system has three inputs I1I1, I2I2, and SS as well as
    11·1 answer
  • Describe how a cavity wall works and sketch its major construction features. What aspects of cavity wall construction are most c
    5·1 answer
  • A 1/4" nut driver with a 1.52 inch diameter handle is used to install a 14" 6 UNC
    13·1 answer
  • Question 8 (1 point)
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!