answer.
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
Ne4ueva [31]
2 years ago
14

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:
slavikrds [6]2 years ago
6 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.

Damm [24]2 years ago
3 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()

You might be interested in
Memory is a _____________ that includes the organization and shaping of information by processing, storage, and retrieval of inf
vaieri [72.5K]

Answer:

A. <em>Encoding Process </em>

Explanation:

Memory is an <em>encoding process </em>that includes the organization and shaping of information by processing, storage, and retrieval of information.

There are two types of memory in computing, <em>RAM </em>and <em>ROM</em>. <em>RAM </em>stands for <em>Random Access Memory</em>. It I the core memory of the computer and it is especially faster regarding reading and writing process. As an analogy, RAM memory is like the “<em>Short-term</em>” memory of the computer. <em>ROM </em>stands for <em>Read-Only Memory</em>, this is the type of memory in charge of permanently storing data in the computer. It contains the necessary information to run the computer. As an analogy, <em>ROM </em>memory is like the “<em>long-term</em>” memory of the computer.

3 0
1 year ago
Wesley has to create a web banner to announce a “Back to School” sale by an online retailer. Which information should he determi
olganol [36]
I would say A :)))))))
4 0
2 years ago
Read 2 more answers
Edhesive Assignment 3: Chatbot on Python
marta [7]

Answer:

Explanation:

Easy peasy lemon squeezy

print: ("hey how are you why are you what are you")

print: ("1,2,3:"):

eif: ("1"):

print: ("nothing")

eif: ("2"):

print: ("Well i am doing this")

eif: ("3):

print: ("watched pewdiepie")

4 0
1 year ago
Read 2 more answers
The Vice President (VP) of Customer Support for Universal Containers has issued a mission statement that "We will empower our cu
elena-14-01-66 [18.8K]

Answer: The three most appropriate options are:

options C, D E

Explanation:

(1) Enabling customers to be emailed FAQs by accessing the interactive voice response 24 hours a day helps consultant achieve mission statement.

(2) Also, mobile devices should have the same support as desktops for mobile devices customer community and should be well optimized.

(3) Consultant will achieve mission statement if a central "Contact Us" page is created which provides access to all available channels.

3 0
2 years ago
Suppose that the following processes arrive for execution at the times indicated. Each process will run for the amount of time l
Len [333]

Answer:

a) 10.53

b) 9.53

Explanation:

a) Average Turnaround Time: ( (8-0)+(12-0.4)+(13-1.0) ) / 3 = 10.53

b) Average Turnaround Time: ( (8-0)+(13-0.4)+(9-1.0) ) / 3 = 9.53

5 0
2 years ago
Other questions:
  • Suppose the algorithms used to implement the operations at layer k is changed. how does this impact services at layers k-1 and k
    10·1 answer
  • When you examine a computer chip under a microscope, what will you see?
    6·1 answer
  • Java languageThe cost to ship a package is a flat fee of 75 cents plus 25 cents per pound.1. Declare a constant named CENTS_PER_
    5·2 answers
  • Please answer this a due tomorrow!!!
    12·1 answer
  • Which of the following statements is incorrect? An operating system provides an environment for the execution of programs. An op
    15·1 answer
  • You'd like to change the minimum password length policy in the Default Domain Policy group policy preference (GPO). What's the b
    10·1 answer
  • Complete this truth Table. Write a program that you can enter from the keyboard, a 1 or 0 into three Boolean variables, A,B,C. W
    14·1 answer
  • Which decimal value (base 10) is equal to the binary number 1012?
    5·1 answer
  • Provide an example by creating a short story or explanation of an instance where availability would be broken.
    10·1 answer
  • Select all the activities Samil could so through his banking app.
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!