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]
4 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:
azamat4 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
Algorithm for converting decimal into binary.
belka [17]
The simplest way is to make for loop first you need to<span> generate 1,2,4,8,16,32,64,128,256....and others number in Array. Then you will check every number. Like this.</span>
<span>Decimal </span>Input 84;
64 is closest to 84.
84-64=20
<span>Write: </span>1
20-32=-12(Because It's negative you will write 0)
Write:10
20-16=4
<span>Write: </span>101
4-8=-4 (Negative)
Write:1010
4-4=0
<span>Write: </span>10101
0-2=-2
0-1=-1
<span>Write: </span><span>1010100 = 84</span>
7 0
4 years ago
Which of the following is NOT correct concerning database design? Question 2 options: Identify all fields needed to produce the
PtichkaEL [24]

The option which is not correct concerning database design is identify all fields needed to produce the required information.

What is database design?

The database design is the arrangement of the data or the information, according to the model of database.

Let's check all the option one by one,

  • Identify all fields needed to produce the required information- This does not concern with the database design.
  • Group related fields into tables-A relation database design consist of one or more than one related table. These tables are used together when the information is required.
  • Determine each table's primary key- To determine the table's primary key, is the concern with the database design.
  • Organize each piece of data into its largest useful part-The database design is the organization of data in the model of database.

The option which is not correct concerning database design is identify all fields needed to produce the required information.

Learn more about the database design here;

brainly.com/question/25694408

8 0
3 years ago
Describe the concepts of Defense in Depth and Detection in Depth. Compare and contrast. What's different? What's similar?
olchik [2.2K]

Answer:

 The main concept of the defense in depth is that the various defensive mechanism series are used for protecting the data and the information in the system. This approach is basically used multiple layers to control the cyber security. It also mainly provide the redundancy for controlling the security failure in the system.

The detection in depth basically provide the redundant overlapping approach and it is used for detecting the security and also accomplish the response that are available in the security detection.  

5 0
4 years ago
What type of stone was the most common building material of royal pyramid?
eimsori [14]
I think it's low grade lime stone..
6 0
3 years ago
Helps locate Web pages
mario62 [17]
What do you need help with here?
3 0
4 years ago
Other questions:
  • Which best compares and contrasts visual and performing arts? Both careers use communication skills; however, people involved in
    15·2 answers
  • Game designers use background images to _______ .
    8·1 answer
  • Why were the spices in Asia so expensive when sold in Europe?
    11·2 answers
  • A company that wants to send data over the Internet has asked you to write a program that will encrypt it so that it may be tran
    6·1 answer
  • Which one of the following may be used as an input as well as an output device? A. Fax machine B. Scanner C. Printer D. Voice re
    9·1 answer
  • count multiples(num1, num2, AND) Description: Returns the number of multiples of N that exist between num1 and num2 inclusive. P
    12·1 answer
  • What is being identified when antibodies stick to pathogens during immunostaining?
    11·1 answer
  • A small business utilizes a SOHO router and wishes to secure its existing wireless infrastructure. The business has fewer than t
    12·1 answer
  • 1. What are the advantages and disadvantages of the digital darkroom as compared to a regular darkroom?
    15·1 answer
  • When we connect to a story, it can be mental, emotional, or even physical. <br> True or False?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!