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
An incoming signal is at a frequency of 500kHz. This signal needs to be acquired and all other signals attenuated. Design a pass
Finger [1]

Answer:

C_h = 0.166 nF

C_L = 0.153 nF  

Explanation:

Given:

- Ideal frequency f_o = 500 KHz

- Bandwidth of frequency BW = 40 KHz

- The resistance identical to both low and high pass filter = 2 Kohms

Find:

Design a passive band-pass filter to do this by cascading a low and high pass filter.

Solution:

- First determine the cut-off frequencies f_c for each filter:

           f_c,L for High pass filter:

                f_c,L = f_o - BW/2 = 500 - 40/2

                f_c,L = 480 KHz

          f_c,h for Low pass filter:

                f_c,h = f_o + BW/2 = 500 + 40/2

                f_c,h = 520 KHz

- Now use the design formula for R-C circuit for each filter:

           General design formula:

                 f_c = 1 /2*pi*R*C_i

           C,h for High pass filter:

                  C_h = 1 /2*pi*R*f_c,L

                  C_h = 1 /2*pi*2000*480,000

                  C_h = 0.166 nF          

           C,L for Low pass filter:

                  C_L = 1 /2*pi*R*f_c,h

                  C_L = 1 /2*pi*2000*520,000

                  C_L = 0.153 nF          

7 0
3 years ago
A 2-mm-diameter electrical wire is insulated by a 2-mm-thick rubberized sheath (k = 0.13 W/m ? K), and the wire/sheath interface
Svet_ta [14]

Question

A 2-mm-diameter electrical wire is insulated by a 2-mm-thick rubberized sheath (k = 0.13 W/m.K), and the wire/sheath interface is characterized by a thermal contact resistance of Rtc = 3E-4m².K/W. The convection heat transfer coefficient at the outer surface of the sheath is 10 W/m²K, and the temperature of the ambient air is 20°C.

If the temperature of the insulation may not exceed 50°C, what is the maximum allowable electrical power that may be dissipated per unit length of the conductor? What is the critical radius of the insulation?

Answer:

a. 4.52W/m

b. 13mm

Explanation:

Given

Diameter of electrical wire = 2mm

Wire Thickness = 2-mm

Thermal Conductivity of Rubberized sheath (k = 0.13 W/m.K)

Thermal contact resistance = 3E-4m².K/W

Convection heat transfer coefficient at the outer surface of the sheath = 10 W/m²K,

Temperature of the ambient air = 20°C.

Maximum Allowable Sheet Temperature = 50°C.

From the thermal circuit (See attachment), we my write

E'q = q' = (Tin,i - T∞)/(R'cond + R'conv)

= (Tin,i - T∞)/(Ln (r in,o / r in,i)/2πk + (1/(2πr in,o h)))

Where r in,i = D/2

= 2mm/2

= 1 mm

= 0.001m

r in,o = r in,i + t = 0.003m

T in, i = Tmax = 50°C

Hence

q' = (50 - 20)/[(Ln (0.003/0.001)/(2π * 0.13) + 1/(2π * 0.003 * 10)]

= 30/[(Ln3/0.26π) + 1/0.06π)]

= 30/[(1.34) + 5.30)]

= 30/6.64

= 4.52W/m

The critical radius is unaffected by the constant resistance.

Hence

Critical Radius = k/h

= 0.13/10

= 0.013m

= 13mm

5 0
3 years ago
Given the system of equations−3x2+7x3=2,x1+2x2–x3=3,5x1−2x2=2(a). Compute the determinant. (b). Use Cramer’s rule to solve for t
34kurt

Answer:

(x1,x2,x3)=(0.985507,1.463768,0.913043)

Explanation:

<em>note: </em>

<em>solution is provided in word document please find the attached document.</em>

Download docx
5 0
3 years ago
What is bubble sort?what is bubble sort ​
juin [17]

Answer:

Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted.

Explanation:

Look at the photo

Good luck

4 0
3 years ago
Read 2 more answers
Sea A una matriz 3x3 con la propiedad de que la transformada lineal x → Ax mapea R³ sobre R³.
skelet666 [1.2K]

Answer:

ax

Explanation:

7 0
3 years ago
Other questions:
  • A metal rod, 20 mm diameter, is tested in tension (force applied axially). The total extension over a length of 80 mm is 3.04 x
    8·1 answer
  • What are factor of safety for brittle and ductile material
    5·1 answer
  • A ceramic material can be defined as an organic compound consisting of a metal or semimetal and one or more nonmetals: (a) true
    9·1 answer
  • Felix has placed some Copper wire (where the official looked up inferred absolute temperature is 234.5 Celsius) 28 gauge wire in
    14·1 answer
  • One kilogram of air, initially at 5 bar, 350 K, and 3 kg of carbon dioxide (CO2), initially at 2 bar, 450 K, are confined to opp
    14·1 answer
  • The following displacement (cm), output (V) data have been recorded during a calibration of an LVDT. Displacement (cm), output (
    15·1 answer
  • Toddlers are children from three to four years of age.<br> True<br> False
    15·2 answers
  • Pls i need help with this
    6·1 answer
  • What is the function rule for the line? f(x)=−32x−2f(x)=−23x−2f(x)=32x−2f(x)=−32x+2A coordinate grid with x and y axis ranging f
    6·1 answer
  • A hydrological system consists of five horizontal formations with an equal thickness of 10 m each. The hydraulic conductivities
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!