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
olga55 [171]
3 years ago
8

#Write a function called find_median. find_median #should take as input a string representing a filename. #The file correspondin

g to that filename will be a list #of integers, one integer per line. find_median should #return the medi
Computers and Technology
1 answer:
azamat3 years ago
5 0

Answer:

Explanation:

The following is written in Python. It takes in a file, it then reads all of the elements in the file and adds them to a list called myList. Then it sorts the list and uses the elements in that list to calculate the median. Once the median is calculated it returns it to the user. The code has been tested and the output can be seen in the image below.

def find_median(file):

   file = open(file, 'r')

   mylist = []

   for number in file:

       mylist.append(int(number))

   numOfElements = len(mylist)

   mylist.sort()

   print(mylist)

   if numOfElements % 2 == 0:

       m1 = numOfElements / 2

       m2 = (numOfElements / 2) + 1

       m1 = int(m1) - 1

       m2 = int(m2) - 1

       median = (mylist[m1] + mylist[m2]) / 2

   else:

       m = (numOfElements + 1) / 2

       m = int(m) - 1

       median = mylist[m]

   return median

print("Median: " + str(find_median('file1.txt')))

You might be interested in
C program To print odd numbers from 15 to 1 ​
inn [45]

Answer:true

Explanation:

This statement is correct

4 0
2 years ago
Which sentence(s) below are true?a. IP stands for Internet Protocol.b. In most home networks IP addresses are assigned by the In
Setler79 [48]

Option A is true because IP is short form of Internet protocol.

Option B is true because when every device is connected to the servers by using internet, Internet Service providers assign them unique IP address to define their identity on internet and monitor their activities.

Option C is false because no matter how many laptops or devices are connected to a same router through a network Internet Service Providers assign them a same IP address.

Option D is true because every laptop or device connected to the internet by a network is given the same public IP or external IP.

8 0
2 years ago
16.
dimaraw [331]
  • Answer:

<em>r = 15 cm</em>

  • Explanation:

<em>formula</em>

<em>V = πr²×h/3</em>

<em>replace</em>

<em>4950 = 22/7×r²×21/3</em>

<em>4950 = 22/7×r²×7</em>

<em>4950 = 22×r²</em>

<em>r² = 4950/22</em>

<em>r² = 225</em>

<em>r = √225</em>

<em>r = √15²</em>

<em>r = 15 cm</em>

3 0
3 years ago
Peter is software designer working at a big software company. He just found out that he has been shifted to their downtown branc
sweet [91]

The managers at Peter’s company have an Autocratic environment.

<u>Explanation:</u>

The managers who are autocratic in nature make decisions on their own. They will never get insights of their employees and they will not take the inputs of them in taking any decisions. This type of management is suitable in an organisation where there is an urgent need to taking decisions to any matter.

Managers who are autocratic in nature will make decisions without consulting anyone's advice.  This type suits those organisations wherein there are very less number of employees. Here, the manager of Peter did not consulted peter in making decisions related to him, the environment is authoritarian or autocratic.  

7 0
3 years ago
You plan to use the Fill Down feature on a formula and you need to keep a cell reference the same. Which of the following format
yKpoI14uk [10]
A $E19 I now it because I am in college
6 0
3 years ago
Read 2 more answers
Other questions:
  • Match the tool to its description.
    15·1 answer
  • Under which menu option of a word processing program does a star appear
    8·1 answer
  • I WILL MARK BRAINLIEST PLZ HELP
    5·1 answer
  • Two powerboats are about to cross paths. what should the boat on the starboard (right) do?
    11·1 answer
  • Provide examples of the cost of quality based on your own experiences
    14·1 answer
  • What is a Hard Drive
    13·1 answer
  • When Creating a FPS game what basic rules would you add?
    12·1 answer
  • Mô tả những lợi ích của việc sử dụng đa xử lý không đồng nhất trong một hệ thống di động
    8·1 answer
  • I need help pls help me
    8·1 answer
  • How do you get lugia in pokemon alpha saphire
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!