answer.
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]
2 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]2 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
5.11 Of these two types of programs:a. I/O-boundb. CPU-boundwhich is more likely to have voluntary context switches, and which i
Leno4ka [110]

Answer:

The answer is "both voluntary and non-voluntary context switch".

Explanation:

The description to this question can be described as follows:

Whenever processing requires resource for participant contextual switch, it is used if it is more in the situation of I/O tied. In which semi-voluntary background change can be used when time slice ends or even when processes of greater priority enter.

  • In option a, It requires voluntary context switches in I /O bound.
  • In option b, it requires a non-voluntary context switch for CPU bound.
7 0
2 years ago
Kelli is unable to find a shape that meets her needs which feature in PowerPoint should she use to create shapes that are comple
sergij07 [2.7K]

In order to customize a shape, Kelli should first add a basic shape and select it. After that, she needs to access the format tab where she can find the option to edit the selected shape. She can modify the selected shape or change it to a free-form according to her needs.

<u>Explanation:</u>

Microsoft PowerPoint provides an easy way for customizing the shapes according to the needs of the user.

Although PowerPoint provides many basic shapes that suit the need of most of the users but in exceptional cases, changes are always welcome. So in order to customize a shape, she should follow the steps which has been explained above.

5 0
2 years ago
A traffic signal system will only operate if it receives an output signal (D=1) This only can occur if: Either (a) signal A is R
kozerog [31]

Answer:

0

Explanation:

4 0
1 year ago
The code selection above is taken from the Color Sleuth activity you just completed. This selection would count as an abstractio
Vinvika [58]

Answer:

b

Explanation:

4 0
2 years ago
How do you think your ability to work might be affected if you don’t magnify a document so that text is at a size for you to rea
max2010maxim [7]

Answer:

It will have a negative effect on the quality of your work for sure.

Without being able to properly and easily read the text, you will not be able to distinguish between symbols that are similar... like "," vs "." or ';' vs ":" or "m" vs "n" or "I" vs "i", and so on.

You might not be able to see where a sentence stops and you'll keep reading, mixing up sentences and wonder why this is in the same sentence.

If you're dealing with a language with accents (like French or Spanish for example), you will not be able to distinguish the accents ("ê" vs "ë" for example).

5 0
2 years ago
Other questions:
  • A windows host sends a tcp segment with source port number 1200 and destination port number 25. the sending host is a(n) _______
    10·1 answer
  • Column, bar, pie, line, and scatter are all types of_____
    9·1 answer
  • Match each logical function with its description. AND COUNTIF SUMIF IF tests for a certain condition and returns one of two valu
    7·1 answer
  • 3.5 Code Practice
    11·2 answers
  • To operate a vehicle in Florida, you must _____.
    9·2 answers
  • The vast amount of data collected from Internet searches, social media posts, customer transactions, military
    8·1 answer
  • Define a structure type auto_t to represent an automobile. Include components for the make and model (strings), the odometer rea
    13·1 answer
  • A colleague sent you an awesome article about using proper ergonomics while sitting at the computer. You don't have time to read
    11·1 answer
  • Write a static generic method PairUtil.minmax that computes the minimum and maximum elements of an array of type T and returns a
    7·1 answer
  • Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!