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
sertanlavr [38]
3 years ago
9

Write a program that computes and prints the average of the numbers in a text file. You should make use of two higher-order func

tions to simplify the design.
An example of the program input and output is shown below:




Enter the input file name: numbers.txt




The average is 69.83333333333333



______________________________________




Filename: numbers.txt




45 66 88



100 22 98
Computers and Technology
1 answer:
KengaRu [80]3 years ago
6 0

Answer:

Following is the program code as required.

Comments are given inside the code.

Explanation:

(=> Defining the main function)

def main():

(=> Getting input from user)

file = input("What is name of file?")

(=>Storing text from file in variable data )

data = open(file, "r")

(=> read the file and then split it)

info = data.read().split()

(=> Generating array named numbers)

numbers = []

for line in info:

(=>numbers will be appended from in format to list format)

numbers.append(int(line))

data.close()

(=> Average will be found by dividing sum of numbers to length of array)

avg = float(sum(numbers))/len(numbers)

(=> Printing calculation of average)

print("Calculated average is",avg)

main()

<h2>i hope it will help you!</h2>
You might be interested in
How are computers 35 years ago and how are they presently and how are they going to be in the next 35 years
antoniya [11.8K]
Answer:

Jason = <span>20yrs.old</span>

Mandy = <span>15yrs.old</span>

Explanation:

Let

J = Jason's age

M = Mandy's age

<span>J+M=35</span> ..... eq. 1

<span>J−10=2<span>(M−10)</span></span> ..... eq. 2

From eq. 1

<span>J=35−M</span>

Substitute this in eq. 2.

<span><span>(35−M)</span>−10=2<span>(M−10)</span></span>

<span>35−10−M=2M−20</span>

<span>35−10+20=2M+M</span>

<span>45=3M</span>

<span><span>453</span>=<span><span>3M</span>3</span></span>

<span>15=M</span>

<span>J=35−M</span>

<span>J=35−15</span>

<span>J=<span>20</span></span>

5 0
3 years ago
How do solar system and galaxies differ?
Cloud [144]
-- A galaxy is a collection of a huge number of stars ... possibly hundreds
of billions of stars in a galaxy. 

-- If a star has planets in orbit around it, then the star and its planets make up
one solar system.

-- There could be hundreds of billions of solar systems in one galaxy.
6 0
4 years ago
windows 93 it is a website THE QUESTION IS WHAT IS THE FIRST THING THAT POPS UP WHEN YOU OPEN THE WEBSITE?
dybincka [34]

Answer:

A black screen with green text in the top left corner

Explanation:

8 0
3 years ago
When using a public computer or network, you should always _______. A. install a firewall. B. run an anti-virus program beforeha
SpyIntel [72]
Answer is c log out of any sites you have logged into ..bc it's a public computer
5 0
3 years ago
Read 2 more answers
What is the key value proposition of Google Search campaigns?A. Appear as a text ad, a video ad, or a banner ad on one of Google
crimeas [40]

Answer:

The correct option is D: Show your ads when a customer is searching for your product or service

Explanation:

Google Search Campaigns allows for advertisement display when you run a search on Google Search. It then displays the result of the search in the search results. The key value proposition of Google Search Campaigns is "Show your ads when a customer is searching for your product or service". Google Search Campaigns are known to be a very popular online advertising form.

5 0
3 years ago
Other questions:
  • Which of the following is the best subject line for an e-mail sent to co-workers about rescheduling a team meeting? A. Reschedul
    12·2 answers
  • 06.04 what's the big idea?
    15·1 answer
  • What do workspaces allow a company to do?
    9·1 answer
  • A location in space is called?
    6·2 answers
  • A file with a com extension is most likely to be a(n) ___ file.
    13·2 answers
  • LAB: Count multiples (EO)
    5·1 answer
  • Please help I’ll mark brainliest!
    12·2 answers
  • Which of the following is referred to as "keeping up with the Joneses"?
    13·1 answer
  • Select the correct answer from each drop-down menu.
    5·2 answers
  • Select the correct answer.
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!