xclorenzo97 xclorenzo97
  • 12-06-2021
  • Computers and Technology
contestada

How do you find the average length of words in a sentence with Python?

Respuesta :

yme304002
yme304002 yme304002
  • 12-06-2021

Answer:

split() wordCount = len(words) # start with zero characters ch = 0 for word in words: # add up characters ch += len(word) avg = ch / wordCount if avg == 1: print "In the sentence ", s , ", the average word length is", avg, "letter." else: print "In the sentence ", s , ", the average word length is", avg, "letters.

Answer Link

Otras preguntas

William has 19 tiles. Elizabeth has 3 fewer tiles than William. Write the expression that can be used to find the total number of tiles they have altogether.
Taxi service x charges $8 as the base fare and $2.50 per mile. Taxi service y charges $4.50 per mile with no base fare. After how many miles is the cost of the
What impact did the spoils system have on American government?
Which describes the wavelength of a wave? A. the distance from the crest to the rest position B. the distance from one point on a wave to the next similar po
N Christopher Marlowe's The Tragical History of Doctor Faustus, why did Faustus begin to believe that human salvation was impossible?
110% of 90 is what number
Asta made a fraction number line to help her multiply 3 x 4/5
How much potential energy does a 40-N medicine ball gain when it is lifted 5 m? Select one: a. 20 J b. 100 J c. 200 J d. 1,000 J
what is the term of social media
Asta made a fraction number line to help her multiply 3 x 4/5