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

one gallon is equal to how many cups
y=3(x+5)(x-2) equivalent to
Simplify 4x - (2-3x) +5
Given f(x)=2x^2+8 and g(x)=5x-6, find each function. (f+g)(x) (f*g)(x)
what is the relationship between the 3s in the number 9, 338
what are some causes of the revolutionary war
Does a right triangle have the same number of right angles as a hexagon?
The perimeter of a rectangular garden is 100 feet. Find the width if the length is 35 feet
5 squares are placed end to end as below (see pic). What is the perimeter of the rectangle formed by the squares? 2b) If the value of x is 2.1cm, what is the pe
Francois baked just enough cookies to fill all the orders at his bakery. While the cookies were cooling, a kitchen assistant knocked over a cooling rack and sp