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
Artist 52 [7]
3 years ago
5

If you have downloaded this book's source code from the companion Web site, you will find a file named text.txt in the Chapter 1

2 folder. (The companion Web site is at www.pearsonhighered/gaddis.) The text that is in the file is stored as on sen- tence per line. Write a program that reads the file's contents and calculates the average of words per sentence.
Computers and Technology
1 answer:
Lubov Fominskaja [6]3 years ago
6 0

Answer:

Explanation:

The following python code loops through each line within a file called text.txt and counts all the words, then it divides this count by the number of sentences in the text file. Finally, output the average number of words per sentence.

f = open("text.txt", "r")

all_words = 0

sentences = 0

for x in f:

   list = x.split(' ')

   all_words += len(list)

   sentences += 1

average = all_words / sentences

print("There are an average of " + str(average.__round__()) + " words in each sentence.")

You might be interested in
How are overhead projectors being used to improve teaching and learning in the classroom?
baherus [9]
<span>Projects are easier to organize in programs like PowerPoint. Also it is definitely a lot less Complicated than a chalkboard or a whiteboard.</span>
6 0
3 years ago
Read 2 more answers
What is the name for unwanted software that installs you to click some links?
Natali5045456 [20]

the answer is malware

7 0
3 years ago
Read 2 more answers
An Identity Theft Report is a combination of a police report and a report submitted to which of the following organizations
DENIUS [597]
Nut Busting Orgainazation
7 0
4 years ago
Why doesn't brainly give me 15 questions a day
Lilit [14]
I’m not sure how to answer that
8 0
3 years ago
Read 2 more answers
Which of the following is not a scene mode?
tatiyna
I believe the answer is C) Model.
7 0
4 years ago
Read 2 more answers
Other questions:
  • In Python, what kind of error is returned by the following code? (e.g. NameError, ValueError, IOError, etc.) def my_func(n1, n2)
    8·1 answer
  • EIPP:________.
    9·2 answers
  • 20 POINTS!
    15·1 answer
  • As a culture chnages so does its language<br><br> A.true <br> B.false
    5·1 answer
  • Which is the answer?
    12·2 answers
  • Which column and row references are updated when you copy the formula f$3/15
    14·1 answer
  • Which type of application architecture has a logic tier
    15·2 answers
  • Explain the procedure you will undertake to create a new partition​
    6·1 answer
  • Terence creates software requirements specification (SRS) documents for various software development projects. In which phase of
    6·1 answer
  • Listed three functions tht are ysed in a spreadsheet​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!