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
WITCHER [35]
3 years ago
15

Assume that a file containing a series of integers is named numbers.txt. Write a program that calculates the average of all the

numbers stored in the file. The input file may have numbers all on one line or several lines or one number on each line.
Computers and Technology
1 answer:
Anna [14]3 years ago
8 0

Answer:

Program in Python:

file = open("numbers.txt", "r")

count = 0

isum = 0

content = file.readlines()

for nums in content:

    num = nums.rstrip('\n').split(" ")

         for i in num:

              isum= isum + int(i)

              count = count + 1

print("Average: "+str(isum/count))

Explanation:

This line opens the file named numbers.txt

file = open("numbers.txt", "r")

This line initializes num to 0

count = 0

This line initializes sum to 0

isum = 0

This line reads the content of the opened file file

content = file.readlines()

This iterates through the content of the file

for nums in content:

This removes trailing new lines and blank spaces from each number

    num = nums.rstrip('\n').split(" ")

This also iterates through the content of the file

         for i in num:

This calculates the sum of the numbers in the file

              isum= isum + int(i)

This counts the numbers in the file

              count = count + 1

This calculates and prints the average of the numbers

print("Average: "+str(isum/count))

You might be interested in
How can you make your MakeCode micro:bit program display either the letter<br> A or the letter B?
Liula [17]

Answer:

Use a random number and control structure to decide which letter is displayed.

Explanation:

8 0
2 years ago
In a PERT network, non-critical activities that have little slack need to be monitored closely
kozerog [31]

Answer: b)because near-critical paths could become critical paths with small delays in these activities

Explanation: Program evaluation and review technique(PERT) technique is used for management of the project .The organizing, maintenance,coordination of any task is done by this chart. The non-critical activities need to be observed carefully because they may create near-critical methods which can lead to complexity.

Other options are incorrect because not all activities are equally rather monitoring is done to avoid errors and slack can occur at any path . Small delays can be caused but not complete project can get delayed and there can be risk of complexity rather than being uncompleted.Thus, the correct option is option(b).

6 0
3 years ago
What is a symbol such as a heavy dot or another character that precedes a text in a power point
Fantom [35]

Answer:

<em>I </em><em>think </em><em>the </em><em>answer </em><em>is </em><em>a </em><em>bullet.</em>

<em>Hope </em><em>this </em><em>helps</em>

4 0
1 year ago
Which organization plays a key role in development of global health informatics?
tensa zangetsu [6.8K]

Answer:

International Medical Informatics Association (IMIA)

Explanation:

In respect of the question which askabout the organization who play an important role in regards to the development of global health informatics is International Medical Informatics Association (IMIA).

International Medical Informatics Association (IMIA) which is an interni association which are independent which works toward expanding and sustaining of global Biomedical and Health Informatics community and give maximum support to international initiative which are geared towards providing adequate and standardized health for each and everyone in the world at large.

3 0
3 years ago
Expressions coded in the HAVING clause
HACTEHA [7]

Answer:

A

Explanation:

Expressions coded in the HAVING clause can use either aggregate search conditions or non-aggregate search conditions.

Cheers

7 0
3 years ago
Other questions:
  • Assume a 8x1 multiplexer’s data inputs have the following present values: i0=0, i1=0, i2=0, i3=0, i4=0, i5=1, i6=0, i7=0. What s
    8·1 answer
  • I need to write a program that accepts eight int values representing student test scores from the user and then displays each of
    14·1 answer
  • This is going to get taken down but I dont care add me on discord cause ima bored<br> -Red-#9847
    12·1 answer
  • )in the link based implementation of the ADT sorted list what is the worst case time efficiency of the remove method?
    7·1 answer
  • What types of storage can be used to access your data on another computer?
    6·2 answers
  • How do you add a PDF assignment to google docs and be able to edit it?
    13·1 answer
  • An email message containing a warning related to a non-existent computer security threat, asking a user to delete system files f
    6·1 answer
  • Could I use a prepaid card to buy a Brainly membership because I tried to get the trial with a low balance but more than like 5$
    11·1 answer
  • When using correct ergonomic technique be sure to _____.
    11·2 answers
  • Tinh T = a1*a2*a3*...an<br><br> Giúp em với
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!