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
tester [92]
3 years ago
9

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

reads through the file, ignoring those value that are not bigger than the maximum value read up to that point. The numbers that are NOT ignored are added, and their sum stored in a variable called runsum.
Computers and Technology
1 answer:
Reptile [31]3 years ago
8 0

Answer:

  1. with(open("numbers.txt")) as file:
  2.    data = file.readlines()  
  3.    runsum = 0
  4.    largest = 0
  5.    
  6.    for x in data:
  7.        if(int(x) > largest):
  8.            largest = int(x)
  9.            runsum += largest  
  10.    
  11.    print(runsum)

Explanation:

The solution code is written in Python 3.

Firstly, open a filestream for numbers.txt (Line 1) and then use readlines method to get every row of data from the text files (Line 2).

Create a variable runsum to hold the running sum of number bigger than the maximum value read up to that iteration in a for loop (Line 3).

Use a for loop to traverse through the read data and then check if the current row of integer is bigger than the maximum value up to that point, set the current integer to largest variable and then add the largest to runsum (Line 6 - 9).

At last display the runsum to console terminal (Line 11).

You might be interested in
Write a machine-language program to add the three numbers 2, –3, and 6 and output the sum on the output device. Write it in a fo
olya-2409 [2.1K]

Answer:

Below is the code ...hope it meet the requirements

lda 0, i

adda 6, i

suba 3, i

adda 2, i

STA 0x0010 ,d

CHARO 0x0010 ,d

.end

Explanation:

8 0
3 years ago
The major difference between a calculator and a computer, when performing calculations, is that a
tester [92]
A calculator is slower and needs more human assistance
7 0
3 years ago
Read 2 more answers
On a DTP project, Morgan is preparing digital files to be sent to a printer. Which word describes the activity that Morgan is pe
VladimirAG [237]

In this activity Morgan is preparing the digital files to a printer  on a DTP project.

Explanation:

DTP project is the creation of documents using page layout on a personal computer. The process of printing digital based images directly to variety of media substrates is known as digital processing.

The digital files like PDFs can be sent directly to digital printing press to print on paper, photo paper, fabric and so on.

They have unique fade rates and different sensitives to the various deterioration mechanisms. DTP is used for graphic designers to create documents.

6 0
3 years ago
Read 2 more answers
Public places where you can wirelessly connect to the internet are known as wifi ________.
AleksAgata [21]

<span>Answer - Hotspots</span>

<span>
</span>

<span>Public places where you can wirelessly connect to the internet are known as Wi-Fi hotspots. Common Wi-Fi hotspot locations (where wireless internet connection is offered) include such places as cafes, hotels, airports, and libraries. These businesses usually create hotspots for the use of their customers.</span>

8 0
3 years ago
A pointing device controls the movement of the ____.
andrey2020 [161]
<span>A pointing device controls the movement of the </span>Mouse Pointer
3 0
3 years ago
Other questions:
  • Which information is necessary to determine an object's speed?
    13·1 answer
  • Which is the correct sequence of steps for opening a new document?
    10·2 answers
  • A(n ____ is anything about which data are to be collected and stored.
    8·1 answer
  • Data as a service began with the notion that data quality could happen in a centralized place, cleansing and enriching data and
    15·1 answer
  • Which system utility can you use to troubleshoot a computer that's slow to start by enabling or disabling startup programs?
    7·2 answers
  • Raid level 6 is basically the same as RAID level 5, but it adds a second set of parity bits for added fault tolerance and allows
    7·1 answer
  • Grandma Ester normally gives you hugs for your birthday - one for every year old you are. When you turned 15, she squished you w
    8·1 answer
  • A character with the point size of 10 is about 10/72 of once inch in height
    8·1 answer
  • Which one is the right code
    10·1 answer
  • How many days till earth ends
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!