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]
4 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]4 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
Differences between analog computer and hybrid computer​
aleksandrvk [35]

Answer:

Analog computers only work with continuous numerical data in analog quantities, digital computers can process both non-numerical and numerical data and a hybrid computer is a combination of both analog and digital. A hybrid computer has the accuracy of a digital computer paired with speed of an analog one.

5 0
3 years ago
Read 2 more answers
All of the following are methods to improve the communication of your key messages EXCEPT:
uysha [10]

Answer:

Fill the slides with images and animations

Explanation:

these will most likely distract the audience

6 0
3 years ago
Read 2 more answers
Passwords are usually alphanumeric and usually cannot contain spaces or ________.
vlada-n [284]

Answer:

The answer is A. Punctuation.  A password can contain symbols

Explanation:

3 0
3 years ago
Read 2 more answers
Reusing internal and external components and behaviors maintains a consistent approach
boyakko [2]

<u>Reuse:</u> reusing internal and external components and behaviors maintains a consistent approach.

<h3>What is an e-waste?</h3>

An e-waste is the abbreviation for electronic waste and it can be defined as any electrical or electronic device that have been discarded because they are no longer functional and useful.

This ultimately implies that, e-waste are generally destined for disposal, resale, reuse, refurbishment, or recycling in the long run.

However, the burning of wires from e-waste extracts the following toxic components that are hazardous to human health:

Polybrominated flame reta-rdants

  • Mercury
  • Lead
  • Barium
  • Cadmium

Read more on recycling here: brainly.com/question/25024898

#SPJ1

8 0
1 year ago
The UML models operations by listing the operation name preceded by an access modifier. A(n) ________ indicates a public operati
Nastasia [14]

Answer / Explanation

The question seem not to be complete. It can be found in search engines.

Kindly find the complete question below.

Question

The UML models operations by listing the operation name followed by a set of ____. A plus sign (+) in front of the operation name indicates that the operation is a public one in the UML (i.e., a public method in Java).

Answer:

To properly answer this question, let us first define what a UML is:

UML can be defined as or is simply refereed to as Unified Modelling Language. It is considered as the standard for modeling language that enables designers and developers to specify, visualize, construct and document object or programs made by them in the areas of software systems, Thus, UML makes this objects developed by computer gurus secure and robust in execution.

If we now go back to the question asked while referencing the explanation given of what a UML is, the answer to the question is

parentheses.

However, if the original question being asked is valid, the answer to it would be : sign (+) in front of the operation name

5 0
4 years ago
Read 2 more answers
Other questions:
  • Which of the following is a collection of honeypots used to present an attacker aneven more realistic attack environment?a. Padd
    6·1 answer
  • Helping people keep track on things is the purpose of_____ A database B table C query D form​
    12·1 answer
  • A security administrator wants to empty the DNS cache after a suspected attack that may have corrupted the DNS server. The serve
    12·1 answer
  • What is the computer that is similar to a destop but smaller in size
    8·1 answer
  • The I/O modules take care of data movement between main memory and a particular device interface.A. TrueB. False
    9·1 answer
  • Select one type of mobile phone connectivity you can use to stream videos on a smartphone
    10·2 answers
  • What is a simulation?
    5·2 answers
  • Which of the following is not a common input device?
    6·1 answer
  • How does information promote cooperation and Industry please explain​
    6·1 answer
  • Why are pirated software considered a threat?​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!