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
Which type of navigation involves multiple frames that are linked to a number of other frames?
sesenic [268]

Answer:

1. b)

2. c)

3. c)

4. a)

5. b)

Explanation:

1. and 5. Linear kind of navigation is a system with a sequential manner web pages that are perfect for some sorts of sites that are having information that has to be viewed as a book (5) and when we are talking about that view we are considering one page after another page like we are reading a book. It is also the simplest navigation. This is the explanation for question 1 and question 5.

2. The most well-designed navigation system is an intuitive one because in this design of the website we have website traffic that is easy because it flows from one web page to another web page. It is showing us where to go to find and look for something and even where to go if there is no concrete options for what are we looking for.

3. A Sitemap is referring to the organized hierarchy of links and it is the protocol that is allowing us to search through many links. A Sitemap is having a listing of the URLs for some site and that is why this is the correct answer.

4. In using liner reciprocal navigation the interface should include how frames are left and how many of them are there. The more the frames, the more times the user will spend on them and the site.

8 0
3 years ago
Why green office became popular among businesses? ​
Tanzania [10]

Answer:

Going green has several other benefits for companies. These include tax credits and incentives, improved efficiency, healthier workplaces, and cost savings – for instance by printing less, turning lights off in unused rooms and refilling ink cartridges. Reusing items also reduces waste from plastic packaging.

Explanation:

3 0
3 years ago
Read 2 more answers
PLEASE HURRY!!
PtichkaEL [24]

Answer: I would say the first one

Explanation: I have never seen an interactive button for use in autoformatting at least on a presentation

8 0
3 years ago
Name at least four factors that are looked at when a lender considers whether you are creditworthy.
emmasim [6.3K]
Sepa la verga cx I don't even know this
6 0
3 years ago
2. What may happen if a large number of computer users are attempting to access a Web site at the same time that you are?
Pachacha [2.7K]
The website may crash if it was not built to sustain a large number of viewers.
6 0
3 years ago
Read 2 more answers
Other questions:
  • In memory ads for DIMMs, you notice DDR 2400 CL15 in one ad and PC4 21300 CL9 in another. Which ad is advertising the faster mem
    12·1 answer
  • Concept of CPU scheduler?​
    7·1 answer
  • Jeff is a financial assistant. He needs to create a document for his client that tracks her stocks and calculates the loss or ga
    10·2 answers
  • Visual culture is an area of academic study that deals with the totality of images and visual objects produced in ____________,
    6·1 answer
  • for java ?(Business: check ISBN-13)ISBN-13 is a new standard for identifying books. It uses 13 digits d1d2d3d4d5d6d7d8d9d10d11d1
    9·1 answer
  • Write a program that repeatedly reads in integers until a negative integer is read. The program keeps track of the largest integ
    9·1 answer
  • Write a program to Test if mold is stored in the variable word.
    5·1 answer
  • X274: Recursion Programming Exercise: Cannonballs Spherical objects, such as cannonballs, can be stacked to form a pyramid with
    7·1 answer
  • I have all of the points and brainliest, but it won't level up, I don't know why, anyone know why?
    12·2 answers
  • What is it called when you define a variable for the first time
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!