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
Program ____ let programmers write code using a word processing-like interface.​
kati45 [8]
<span>Program "editor" </span>let programmers write code using a word processing-like interface.​

This is utilized by programming software engineers; gives them a chance to compose code utilizing a word processing like interface that usually includes functions, like, AutoCorrect and AutoComplete.it is also called text editor.
3 0
3 years ago
What are experts in technology who use their knowledge to break into computers and networks, for profit or just as a challenge k
insens350 [35]

Answer:

Hacker

Explanation:

Hacker -

It refers to the computer software expert , who is responsible to break into the unauthorized networks or computer , is referred to as a hacker .

The hacker is skilled with exceptional computer and computer software knowledge .

Hacking is an illegal practice , as the person is able to access some confidential and personal data and information of any other person or organisation .

Hence , from the given information of the question ,

The correct term is hacker .

3 0
3 years ago
you have increase the packet size while using color doppler to evlatue flow. what negative result will occur
swat32

Answer:

You have increased the packet size while using color Doppler to evaluate flow. What negative result will occur from this action? Decreased frame rate. You have increased the packet size while using color Doppler to evaluate flow. Hope this helps! PLEASE GIVE ME BRAINLIEST!!!! =)

3 0
3 years ago
In Python 3, write a decorator function that has the following property:
kicyunya [14]

Answer:

Python code is explained below

Explanation:

# decorator.py starts

def uppercase(fcn):

def wrapper():

original = fcn;

modified = str(fcn).upper() ;

return modified;

return wrapper();

# decorator.py ends

# greet.py starts

import decorator  #to generate the decorator

def greetings():  #invokes the greetings function for output

print("Hello");

print(decorator.uppercase(greetings));

# greet.py ends

8 0
3 years ago
Which graphics element loads faster when used with text or audio on a web page?
Kobotan [32]

An “iframe” maybe idk what is asking

5 0
3 years ago
Read 2 more answers
Other questions:
  • Namespaces cannot have namespaces as members.<br><br> True<br><br> False
    7·1 answer
  • Suppose you have a file of data of approximately 100,000 personnel records (FYI, 213 = 8192 and 214 = 16384) using Social Securi
    12·1 answer
  • What fields of engineering are in Biomedical
    7·1 answer
  • Explain the history of computing of mechanical era
    14·2 answers
  • Your customer asks you if it would be worth the investment for him to have Ethernet cabling installed to reach each of his works
    6·1 answer
  • The famous study entitled ""Protection Analysis: Final Report"" focused on a project undertaken by ARPA to understand and detect
    14·1 answer
  • E-mail messages, instant messages (IMs), or text messages sent and/or received within an organization a. are not included on a r
    9·1 answer
  • If myClass has a constructor with a parameter of type String, select the other constructor that should be included.
    14·1 answer
  • PLEASE HELP
    12·1 answer
  • How do we produce quality work in editing audio?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!