subject

Write a program that receives a filename as user input. The file is structured as multiple lines containing numbers separated by a single space. For example, this would be an acceptable file:
1 2
3
4 5 6
7 2
Your program should open this file and:
print all its contents;
write the median of all numbers to a new file called result. txt.
IMPORTANT NOTES:
the median is the element in the middle when you sort the values;
the median of values (2, 1, 3) is 2, because when you sort them, you get 1, 2, 3, and 2 is the value in the middle.
you can assume there will be no empty lines;
there might be any arbitrary number lines in the file;
there might be any arbitrary number of elements in a single line;
you can assume there will always be an odd number of elements.
Example 1:
If input is:
file1.txt
and the contents of file1.txt are:
1
2
2
you should first print the content, and then write 2 to result. txt.
Example 2:
If input is:
file2.txt
and the contents of file2.txt are:
1 2
3
4
5 1 7
you should first print the content, and then write 3 to result. txt.
The elements sorted are: 1, 1, 2, 3, 4, 5, 7. In this sequence, 3 is the middle value, so it is the median.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 02:30
How to launch an app: steps to be successful? launching an app is a great idea, but it’s not that easy as we supposed to think. the majority of mobile applications don’t generate revenue because companies aren’t ready to be competitive. referring to our experience in successfully building and launching apps we hope to you omit these difficulties. we are going to talk about ideas, marketing, testing your product, its development, distribution and support. you will learn 8 product launch stages to succeed.
Answers: 1
question
Computers and Technology, 24.06.2019 06:30
Adrawing that places all lines parallel to the z axis at an angle from the horizon is 99 ! a. an oblique drawing b. a perspective drawing c. an auxiliary view d. a one-point perspective drawing
Answers: 2
question
Computers and Technology, 24.06.2019 18:20
7. design a circuit with three inputs (x, y, and z) representing the bits in a binary number, and three outputs (a, b, and c) also representing bits in a binary number. when the input is 1, 2, or 3, the binary output should be one lesser than the input. when the input is 4, 5, or 6, the binary output should be one greater than the input. when the input is 0, the output is 0, and when the input is 7, the output is 7. show your truth table, all computations for simplification, and the final circuit.
Answers: 2
question
Computers and Technology, 25.06.2019 08:50
99 points asap ! select the mathematical statement that is true. a.22 % 2 > −3 b.22 % 2 < 5 c.22 % 2 == 4 d.22 % 2 ! = 1 this is for my python coding class you
Answers: 1
You know the right answer?
Write a program that receives a filename as user input. The file is structured as multiple lines con...
Questions
Questions on the website: 13722363