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
Consider that a system has two entities, Students, Instructors and Course. The Student has the following properties: student nam
tekilochka [14]

Answer:

There's no answer ?

Explanation:

5 0
3 years ago
Some of our modern kitchen cookware is made of ceramic materials. (a) List at least three important characteristics required of
Alisiya [41]

Answer:

A)

It should be Non- toxic

It should possess high Thermal conductivity

It should have the Required Thermal diffusivity

B)

  • stoneware : This material has good thermal diffusivity and it  is quite affordable and it is used in making pizza stones
  • porcelain: mostly used for mugs and it is non-toxic
  • Pyrex : posses good thermal conductivity used in oven

C)   All the materials are suitable because they serve different purposes when making modern kitchen cookware

Explanation:

A) characteristics required of a ceramic material to be used as a kitchen cookware

  • It should be Non- toxic
  • It should possess high Thermal conductivity
  • It should have the Required Thermal diffusivity

B) comparison of three ceramic materials as to their relative properties

  • stoneware : This material has good thermal diffusivity and it  is quite affordable and it is used in making pizza stones
  • porcelain: mostly used for mugs and it is non-toxic
  • Pyrex : posses good thermal conductivity used in ovens

C) material most suitable for the cookware.

 All the materials are suitable because they serve different purposes when making modern kitchen cookware

8 0
2 years ago
1: asha started abusness with 30.000
svetoff [14.1K]

Answer:

Explanation:adrive with visual acutity of 20/30 can just decipher asing adistance 20ft from asing determine the maximum destance from the sing which drivers with the flowing visual acuities will able to see the same sing 20/15 20/50

4 0
2 years ago
Una empresa realizó en el ejercicio de compras al contado por valor
Tanzania [10]

Answer:

englishhhh pleasee

Explanation:

we dont understand sorry....

8 0
3 years ago
A reservoir delivers water to a horizontal pipeline 39 long The first 15 m has a diameter of 50 mm, after which it suddenly beco
allsm [11]

Answer:

The difference of head in the level of reservoir is 0.23 m.

Explanation:

For pipe 1

d_1=50 mm,f_1=0.0048

For pipe 2

d_2=75 mm,f_2=0.0058

Q=2.8 l/s

Q=2.8\times 10^{-3]

We know that Q=AV

Q=A_1V_1=A_2V_2

A_1=1.95\times 10^{-3}m^2

A_2=4.38\times 10^{-3} m^2

So V_2=0.63 m/s,V_1=1.43 m/s

head loss (h)

h=\dfrac{f_1L_1V_1^2}{2gd_1}+\dfrac{f_2L_2V_2^2}{2gd_2}+0.5\dfrac{V_1^2}{2g}

Now putting the all values

h=\dfrac{0.0048\times 15\times 1.43^2}{2\times 9.81\times 0.05}+\dfrac{0.0058\times 24\times 0.63^2}{2\times 9.81\times 0.075}+0.5\dfrac{1.43^2}{2\times 9.81}

So h=0.23 m

So the difference of head in the level of reservoir is 0.23 m.

8 0
3 years ago
Other questions:
  • A petrol engine produces 20 hp using 35 kW of heat transfer from burning fuel. What is its thermal efficiency, and how much powe
    14·1 answer
  • What would happen to a plane if the weight force becomes greater than the lift force?
    12·2 answers
  • Which of the following scenarios describes someone who is a materials engineer?
    13·1 answer
  • Explain how the objects in a battery work with its components
    10·1 answer
  • A triangular roadside channel is poorly lined with riprap. The channel has side slopes of 2:1 (H:V) and longitudinal slope of 2.
    9·1 answer
  • A plumbed eyewash station is portable.
    8·1 answer
  • 12. A structural component is fabricated from an alloy that has a plane strain fracture toughness of It has been determined that
    11·1 answer
  • A heat pump with refrigerant-134a as the working uid is used to keep a space at 25C by absorbing heat from geothermal water that
    5·1 answer
  • The majority of adults now own smartphones or tablets, and most of them say they use them in part to get the news. From 2004 to
    7·1 answer
  • 3. If nothing can ever be at absolute zero, why does the concept exist?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!