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
What is the disadvantage of a mesh topology?
-BARSIC- [3]

Answer:

Topology means arrangement of nodes

Explanation:

In computer science the word topology means the arrangement of nodes and elements in a network. For any topology we do need nodes and cables for maintaining the infrastructure.

In mesh topology the all nodes use to get connected by direct link. While each and every node is directly associated with  one another. In this infrastructure we do need lot cabling where every node will be connected with one another. While usage of good quality cable in network is  also expensive to manage. Although there are lot of benefits of this topology, where the transmission of data would never stop if node is not working the rest will be working to transfer the data among other nodes ,this is more secure because there is no traffic for data to travel via many nodes   to reach the destination. Every node is directly connected and communicate. So, once the node is not working the communication will not be stop but the maintenance and troubleshooting will be difficult in this infrastructure.

It is proved along with lot of benefits and network security ,this infrastructure is having some disadvantages as well. Cabling expense , maintenance cost etc  . usually small scale networks do not prefer mesh topology.  Small scale and low budget companies can  not afford this topology because it is expensive.

Although we do believe that the data security is most important for today's era ,so few companies those wanted to keep their information secure and confidential they must use mesh topology by ignoring the cost incurred for this set up. Data security and integrity would never be compromised by some of the companies.

Mesh topology is more safer, more quick infrastructure which is although very expensive , difficult to mange and maintain. Moreover it is overhead of cabling as well to connect every node but the demand of mesh topology would never be less. It is demanding and appealing topology still.

7 0
3 years ago
Read 2 more answers
Which of the following are peripheral devices?
Fittoniya [83]

Explanation:

I think it's speakers,

7 0
3 years ago
Read 2 more answers
How fast is light? person that answers this will get points ​
Serhud [2]

299,792,458 metres per second

6 0
3 years ago
Into which of these files would you paste copied information to create an integrated document? A. Mailing list B. Source C. Data
viva [34]

it would be b.mailing list


5 0
3 years ago
Read 2 more answers
i have been looking for like 20 mins now and cant find the answers to test 3 on edhesive. does anybody have an clue to where i c
frez [133]

Answer:

Try looking it up. If not, go with your gut!

3 0
2 years ago
Other questions:
  • The specifications for ____ are developed by the world wide web consortium (w3c) and are continually evolving.
    13·1 answer
  • How can earn more answer from brainly less than two minutes, please
    9·1 answer
  • A local area network works as a ____ network in that clusters of workstations are connected to a central point (hub or switch) t
    6·1 answer
  • What method of malware infection installs malware through use of a separate browser window that opens uninvited from a Web page?
    7·2 answers
  • Some people are unable to arrange six matches to form four equilateral triangles because they fail to consider a three - dimensi
    6·1 answer
  • When an interrogator speaks highly about how a crime was committed, hoping to get the suspect to brag about his or her involveme
    7·2 answers
  • Which of the following is a technique used by hackers to identify unsecured wireless network locations to other hackers?A. Blues
    10·1 answer
  • A computer operating system software manufacturer invests its profits in creating newer versions of its operating system softwar
    7·1 answer
  • Guys im getting the ps5 tomorrow :)​
    5·2 answers
  • Write a Pascal program that will prompt the user to enter the radius of a circle.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!