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
Savatey [412]
3 years ago
15

Define a function below called average_num_in_file. The function takes one argument: the name of a file full of numbers. Complet

e the function so that it opens the file and returns the average of the numbers in the file. Here is an example input file from the static test case if you want to test from the interpreter: canned_file.txt
Computers and Technology
1 answer:
Nookie1986 [14]3 years ago
7 0

Answer:

  1. def average_num_in_file(fileName):
  2.    with open(fileName) as file:
  3.        rows = file.readlines()
  4.        sum = 0
  5.        count = 0
  6.        for x in rows:
  7.            sum += float(x)  
  8.            count += 1
  9.        average = sum / count  
  10.    return average  
  11. print(average_num_in_file("cans.txt"))

Explanation:

The solution code is written in Python 3.

Firstly create a function that take one parameter, fileName (Line 1).

Open the file stream and use readlines method to read the data from the file (Line 2-3). Create variable sum and count to tract the total of the number from text files and number of data from the file (Line 5-6). Use a for loop to loop over each row of the read data and add the current value of each row to sum and increment the count by one (Line 7-9).

After the loop, calculate the average (Line 11) and return the result (Line 12).

At last, we can test the function by passing the cans.txt as argument (Line 14).

You might be interested in
Please explain what Level 5 Automation is and give 2 examples of the technology.
arsen [322]

Level 5 ( Full Driving Automation ) Level 5 cars won't even have steering wheels or acceleration / braking pedals . They will be free from geofencing , able to go anywhere and do anything that an experienced human driver can do .

Pls follow me and Mark as brainlest!!! :-)

8 0
3 years ago
Jose has 3/5 kilogram of peppermints and 2/3 kilogram of candy canes. How many kilograms of candy does he have?
yarga [219]

Answer:

\frac{19}{15}\\

≅ 1.267

Explanation:

\frac{3}{5} +\frac{2}{3} \\\\= \frac{9}{15} + \frac{10}{15} \\\\= \frac{9+10}{15} \\\\= \frac{19}{15} \\\\= 1.267

6 0
3 years ago
What log file contains information and error messages regarding network access generated by daemons such as ssd and xinetd?
ehidna [41]

Answer:

The correct answer to the following question will be "Secure".

Explanation:

This file includes information about the rights of verification and authorization.

  • It will be used primarily for monitoring the use of authorization schemes.
  • It holds all communications related to safety like faults in encryption.
  • This also monitors sshd logins, logins of SSH, as well as other system security resources daemon-logged failures.

So, it's the right answer.

3 0
3 years ago
Adam, a flower shop owner, wants to drive phone calls to his store. Which Adwords tool should he use to track how many calls res
Kipish [7]

Answer:D)Conversion tracking

Explanation:Conversion tracking is the tool that helps the user to know about the interaction of the ad given by him with customer. It helps in the tracking in the ways like calls from ads, call conversion importing,mobile website gaining the number of clicks etc.

Thus,  Adam needs to use the conversion tracking tool which for driving the calls towards his store.He can track the effectiveness of the ad which drives the calls.

Other options given are incorrect because they cannot keep the record of the  ads seen by the customer with the help of tracking. Thus the correct option is option(D).

8 0
3 years ago
Your company shares a building with a competitor's branch office. Recently, you noticed that some computers other than company c
professor190 [17]

<u>The wireless network:</u>

Wireless networking and internet access are essentials when it comes to the smooth functioning of an enterprise. Certain information can be transferred from one computer to another within a specified if they are connected to a network.

In this case, as the company shares the building with the branch office of a rival company there may be repercussions. First of all, the company's wireless network should be equipped with a strong password and it should be changed regularly too.

Next, the officials responsible for networking should also monitor the range of their wireless network. There is no point in keeping the range of wireless network wide as it is to be used by employees only and they can access it on the company's premises.

5 0
3 years ago
Other questions:
  • __________ involves analyzing a large amount of data to extract knowledge and insight
    13·1 answer
  • Use a colon before a list and put one space after a colon. True False
    15·2 answers
  • An _________ is a phrase formed from the first letters of words in a set phrase or series of words a. Acronymic sentence c. Basi
    7·2 answers
  • What is a data broker?
    6·1 answer
  • Testing for information would be most likely to occur in which type of engineering?
    5·2 answers
  • Question 2 (2 points)
    6·1 answer
  • Mr. O would like to purchase a new computer for his home business. Mr. O's current computer runs very slow when he is running e-
    5·2 answers
  • When creating any digital work, what is the MOST important thing to remember?
    7·1 answer
  • What does a hanging indent look like?
    7·1 answer
  • Does anyone have discord
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!