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
Janeal spends her day looking at the stock and bond markets and evaluating how the portfolios of the businesses she serves will
pychu [463]

Answer:

ur answer good sir will be : financial analyst

and a brainliest will be good to thnx

4 0
4 years ago
Difference between vacuum tube and transistor​
Lorico [155]

Answer:

I HOPE THE ABOVE INFORMATION WILL HELP YOU A LOT.

6 0
3 years ago
What kind of value should an employee possess when employees are expected to be responsible and fair?
WINSTONCH [101]

I'd say professionalism

Professionalism in a workplace setup is acting in a responsible and fair manner in all your personal and work activities. It is always seen as sign of maturity and self-confidence. This work value includes learning every aspect of a job and performing it to the best of your God given ability.

3 0
3 years ago
What is the purpose of using iteration or looping statements in a javascript code
Sonja [21]

In computer science, a loop is a programming structure that repeats a sequence of instructions until a specific condition is met. Programmers use loops to cycle through values, add sums of numbers, repeat functions, and many other things
Loops allow programs to perform repetitive tasks, such as iterating through an array, while adhering to the DRY principle (Don't Repeat Yourself). They come in handy when you want to execute a function a number of times, using different sets of inputs each time.
5 0
3 years ago
Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per li
bonufazy [111]

Answer:

b ,/knlk

Explanation:

5 0
3 years ago
Other questions:
  • 38. Which of the following best describes why e-mail spoofing is easily executed? a. SMTP lacks an adequate authentication mecha
    15·1 answer
  • Write an if/else statement that compares the variable age with 65, adds 1 to the variable seniorCitizens if age is greater than
    14·1 answer
  • Difference between softcopy and hardcopy​
    8·2 answers
  • A Unit of information containing the objects position, rotation, and scale values is called:
    13·1 answer
  • Considering the concept of salted passwords, answer the following questions: a. Bob thinks that generating and storing a random
    10·1 answer
  • To build a framework for security policies and controls, one can use the following approach: 1) document the concepts and princi
    12·1 answer
  • If you are trying to improve your budget and spending, which option would save you the most money?
    13·2 answers
  • Which of these consoles had a 64-bit architecture
    10·1 answer
  • Choose all of the items that represent parts of an operating system.
    6·2 answers
  • WHO WANT P O I N T S.................................................
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!