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
Leno4ka [110]
3 years ago
6

A file named data.txt contains an unknown number of lines, each consisting of a single integer. Write some code that creates two

files, dataplus.txt and dataminus.txt, and copies all the lines of data1.txt that have positive integers to dataplus.txt, and all the lines of data1.txt that have negative integers to dataminus.txt. Zeros are not copied anywhere.
Computers and Technology
2 answers:
dmitriy555 [2]3 years ago
8 0

Answer:

I am doing it with python.

Explanation:

nums = '9 -8 -7 -6 -5 -4 -2 0 1 5 9 6 7 4'

myfile = open('data.txt', 'w')

myfile.write(nums)

myfile.close()

myfile = open('data.txt', 'r')

num1 = (myfile.read())

num1 = num1.split()

print(num1)

print(type(num1))

for x in num1:

   x = int(x)

   if x < 0:

       minus = open('dataminus.txt', 'a')

       minus.write(str(x) + ' ')

       minus.close()

   elif x>= 0:

       plus = open('dataplus.txt', 'a')

       plus.write(str(x)+' ')

       plus.close()

yuradex [85]3 years ago
8 0

Answer:

#section 1

data = open('data.txt', 'r')

num = (data.read())

num = num.split()

data.close()

#section 2  

for x in num:

   x = int(x)

   if x < 0:

       minus = open('dataminus.txt', 'a')

       minus.write(str(x) + ' ')

       minus.close()

   elif x > 0:

       plus = open('dataplus.txt', 'a')

       plus.write(str(x)+' ')

       plus.close()

Explanation:

#section 1

A file data.txt containing an unknown number of lines each containing a single integer is opened.

The data is read from it and split to form a list from which the code will iterate over with a FOR loop and some conditional statements will be used to determine if the number is positive or negative.

#section 2

In this section two new files are created/ opened dataplus.txt and dataminus.txt and all the positive integers are stored in the dataplus.txt and the negative integers in the dataminus.txt.

The IF statement and elif statement used ensures that zero(0) is not captured ensuring that the code fulfills all the requirements in your question.

You might be interested in
A personal business letter is a letter that is ____.
Simora [160]

Answer:

Explanation:

One group of students did an experiment to study the movement of ocean water. The steps of the experiment are listed below.

Fill a rectangular baking glass dish with water.

Place a plastic bag with ice in the water near the left edge of the dish.

Place a lighted lamp near the left edge of the dish so that its light falls directly on the plastic bag.

Put a few drops of ink in the water.

The student did not observe any circulation of ink in the water as expected because the experiment had a flaw. Which of these statements best describes the flaw in the experiment? (2 points)

Not enough ink was added.

Not enough water was taken.

The dish was too small for the experiment.

The lamp and the ice bag were at the same place.

8 0
3 years ago
You can install several printers on your machine, but at least one must be the _______ printer.
Digiron [165]
<span>You can install several printers on your machine, but at least one must be the default printer.
When you have several machines attached to your computer, it is important to designate one of them as the 'default' machines so as to avoid confusion within the system. If you fail to do this, you may create some problems, so be sure to choose a default one.</span>
3 0
4 years ago
You are the IT security administrator for a small corporate network. The HR director is concerned that an employee is doing some
sp2606 [1]

Answer: A, it's the most professional way or C but I'd choose A

7 0
2 years ago
A network administrator has been creating a baseline of network performance. During this process, he realizes that one router is
LiRa [457]

If the network administrator found that one of his routers is slow in performance better to check the traffic packet transactions. If any huge file size is been transferred better to disconnect the router and reconnect.

Possible to kill the network task packet so the network speed can be restored.

<u>Explanation:</u>

Moreover, possible to scan the end-user PC or workstation or desktop whether any malware or spyware is affected, if so better to remove that particular PC or workstation or desktop to disconnected from the router.

Updating the PC or workstation or desktop OS patches to be done at regular intervals.

5 0
3 years ago
(TCO B) The symbol shown as a three-sided box that is connected to the step it references by a dashed line is what?
xxTIMURxx [149]

Answer:

Annotation symbol.

Explanation:

A flowchart can be defined as a graphical representation of an algorithm for a process or workflow.

Basically, a flowchart make use of standard symbols such as arrows, rectangle, diamond and an oval to graphically represent the steps associated with a system, process or workflow sequentially i.e from the beginning (start) to the end (finish).

A symbol shown as a three-sided box in a flowchart, that is connected to the step it references by a dashed line is known as an annotation symbol.

This ultimately implies that, it provides additional information in the form of remarks or comments with respect to the steps in a flowchart.

8 0
3 years ago
Other questions:
  • In what decade did the Internet begin to be used widely by the public and not just government entities?
    5·2 answers
  • What is the purpose for the refresh button?
    10·2 answers
  • Write a function shampoo_instructions() with parameter num_cycles. If num_cycles is less than 1, print "Too few.". If more than
    7·1 answer
  • Which of the following are examples of how a company might use consumer data it had collected? a To decide what types of product
    10·1 answer
  • For Excel:
    5·1 answer
  • Controlling access of information on the internet
    15·1 answer
  • Why is it so important to have employees who can critically think?
    7·2 answers
  • What invention in the past do you think had a significant impact on our culture/ lifestyle? What do you think will be invented/
    11·1 answer
  • (Comparable interface) Write Rectangle class that implements the Comparable interface. Override the equals method so that two Re
    12·1 answer
  • Computer always produces wrong output true or false<br>​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!