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

Why were many Indians unhappy with Oklahoma becoming a state?
If m(x)=2x and n(x)=x-4 find the general rule for m(n(x))
If x is a negative number, which of the following could equal the absolute value of x? Select all that apply. A. -2 B. 2 C. 4 D. 6
a bakery offers a sale price of $3.50 for 4 muffins. What is the price per dozen?
The ratio of boys to girls in a class is 5 to 6 which is an equivalent. Ratio
does madison say it is possible to have tyranny in a democracy ? explain
what is 36/64 in its simplest form
central middle school sold 50 tickets for one night of the school play. student tickets sold for $2 each and adult tickets sold for $3 each. they took in $135.
I don't know how to do the problem 6^4 x 10^2 over 6^2 x 2^4. Do you think you could help?
evaluate the expression 16a squared-4b when a equals 1/4 and b equals 6