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
Ne4ueva [31]
3 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]3 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]3 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
What is the last step in conducting a URL search
MaRussiya [10]
My answer -

<span>i think the last step in conducting a URL search would be : A. The user's browser renders the html code as a visual web page. A web page that we commonly see is structured by a bunch of 1 and 0. Rendering process allow the machine to interpret that 1 and 0 into the visual that we currently seeing Hope this helps.


Note -

Have and AWESOME !!! day I LOVE!!! you let me know if you need additional help! Really gald 2 help</span>
6 0
3 years ago
What did major networks do to combat audience erosion in the 1990s?
S_A_V [24]

Answer: I think is 3. They acquired cable channels. They acquired cable operators.

Explanation:

6 0
4 years ago
N a MenuStrip, if you create each main menu item with a(n) ____ in front of a unique letter, then the user can press Alt and the
Zolol [24]

Answer:

C) &

Explanation:

In the C# programming language a MenuStrip adds a custom menu bar to the program that you are making in which you can create unique menu items. When doing so, if you create a menu item with an & in front of a unique letter, the user can press ALT and the letter to activate the menu choice. These shortcuts are known as Access Keys.

8 0
3 years ago
An automated search feature used by search engines to find that match your search terms is called a spider or
9966 [12]

Answer

Crawler

Explanation

This is a program that go to various website to read their pages and content provided in order to form entries for a search engine index.All search engines have this program called spider or a bot. It acts as an automated script that browses through the internet to scan the web pages and find words contained in the pages and where the words are used.


5 0
4 years ago
Read 2 more answers
Whats the difference between computers and tablets
inysia [295]

Explanation:

Tablets are more portable than any computer or laptop. They are very lightweight and can fit in a purse or small bag with relative ease. They are designed to be taken everywhere with you, thus the very definition of portable.

Storage Computer hard drives can be over one TB (terabyte). Even the most basic computer comes with a 250 GB (gigabyte) hard drive, which for many is more than enough storage for most users. Tablets come with built-in storage ranging from 8 GB to 128 GB. In some cases, an expansion slot may be available for adding additional storage.

Battery life The battery life even for the most efficient laptop is still not close to the battery life of a tablet. A tablet has a much smaller screen and has fewer components than a laptop computer, which makes for a longer battery life.

Operating System Desktop and laptop computers come with more fully featured operating system due to having the computing power and memory requirements. These operating systems support more than any tablet operating system. Tablets come with a more slimmed down operating system because of the limited computing power and memory. The Android OS and Apple iOS are adequate operating systems for tablet users, but not as complete as computer operating systems.

Boot time The latest computers running the latest operating systems have improved a lot on their boot time. However, are still slower than a tablet. Generally speaking, most tablets are much faster at booting than most computers.

Data entry and user input A computer uses a keyboard for data entry that most users are familiar with and comfortable using. The mouse is also available for easy scrolling and right-clicking. Tablets use an on-screen keyboard that is smaller than a standard computer keyboard, takes time to learn, and users with bigger fingers may have a hard time typing. Some tablets allow for an external keyboard, providing a more comfortable and familiar medium for typing.

Touch screen Although some laptops and desktops now support touch, most still have no touch screen support. All tablets support a touch screen, that's easier for new computer.

3 0
3 years ago
Read 2 more answers
Other questions:
  • The term _____ refers to computers that are among the fastest of any in the world at the time of their introduction.
    6·1 answer
  • Many application controls are useful for enhancing the reliability of both transaction data and master record data. This applica
    15·1 answer
  • To mark all modifications made to the document, activate the
    10·2 answers
  • Write a program that accepts a time as an hour and minute. Add 15 minutes to the time, and output the result. Example 1: Enter t
    11·1 answer
  • How does an agile team obtain clarity on backing items that may be picked up in upcoming iterations? (1 correct answer)
    10·1 answer
  • A company accidentally sends a newsletter with a mistyped website address. The address points to a website that has been spoofed
    8·1 answer
  • A human would do a better job determining the shortest route between twenty cities than a computer.
    6·1 answer
  • Select the correct line of missing code to create an output of "hello."
    10·1 answer
  • 8.10 quiz edhesive A swap is: a variable used to find the smallest value in an array an algorithm used to find a value in an arr
    12·1 answer
  • In your own words, explain what it means to “buy low, sell high.”
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!