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]
2 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]2 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
As important as it is to plan ahead, sometimes you_____.
timama [110]

Answer:

B. Can't stop things from doing wrong.

Explanation:

Life is never for certain there are so many unpredictable things that can happen like at one moment you are turning onto the street and you get into a car accident you didn't plan for that to happen. Anything can happen on a day to day basis that's why something can go wrong and all your plans won't work anymore.

4 0
3 years ago
Read 2 more answers
What does a file extension tell you?
kiruha [24]

A. because everyone basically has seen it..

3 0
2 years ago
People of brainly Just a quick warning that there is a group of people posting links with virus.
valina [46]

Answer:

Thank you, they post on EVERY. SINGLE. QUESTION.

Explanation:

They keep posting the same file every time, but they might change the file after seeing this post. Please just don't click any files!

7 0
3 years ago
Read 2 more answers
Make a program that receives several integers (the program ends when a negative number is entered) and shows how many times the
Levart [38]
I really tried to help sorry
5 0
2 years ago
When should you integrate technology?​
earnstyle [38]
Nolur acil lütfen yalvarırım yalvarırım lütfen yalvarırım when should you integrate technology?
5 0
3 years ago
Read 2 more answers
Other questions:
  • If the current through a heater coil is 5 amp and the supply voltage is 120 volts, the coil resistance is A. 0.04 ohm. B. 24 ohm
    6·1 answer
  • Malcolm is part of a team developing a new smartphone app to track traffic patterns. Because team members are located throughout
    12·1 answer
  • When using the following symbol, there are two arrows coming out of it. One arrow corresponds to what happens in the program if
    7·1 answer
  • A bank uses a computer program during the night to tell if the alarm should ring. Sensors in the bank set the following Boolean
    5·1 answer
  • What is ‘Software Testing’?
    13·1 answer
  • Which of the following is a correct group scope type in AD, windows server 2016?
    6·1 answer
  • What is the gear ratio?
    12·1 answer
  • 2.4 Code Practice: Question 2
    5·1 answer
  • 45 points!!
    15·2 answers
  • What type of element addresses the recovery of critical information technology (it) assets, including systems, applications, dat
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!