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
A technician is performing Windows preventative maintenance tasks on all computers in the organization. She wants a way to creat
antiseptic1488 [7]

Answer:

The tool that allows to configure a custom console is "mmc.exe".

Explanation:

MMC is a Microsoft Management Console. It is used to customize the management console and add the tools in console that are required by the technician.

3 0
3 years ago
What is an occupation?​
LiRa [457]

Answer:

a job or profession.

4 0
3 years ago
Photographs that are too dark or too light can be difficult to fix with photo-editing software.
Nana76 [90]
The answer is true :)
6 0
3 years ago
Read 2 more answers
When should you try to photograph reflections on bodies of water?
Wewaii [24]

Answer:  C. although a rainy day (A) would make it more aesthetic

6 0
4 years ago
What are three to five (3-5) key differences and features in Windows Server 2016 versus 2012?
Kipish [7]

Answer:

Find the features and differences below.

Explanation:

Five key features of the 2012 version of the Windows Server include;

1. Metro-style start button which disables the old start button.

2. Hyper V which enables the creation and use of a virtual machine.

3. Resilient file system (ReFS file system), aimed at managing large data and maintaining their integrity.

4. New Windows Task management, and

5. Internet protocol address management

Key features of the 2016 Windows Server include;

1. Nested virtualization

2. Secure boot

3. Nano server

4. Windows container, and

5.  Docker support.

The differences between the two versions are;

1. While the 2016 version would need a hard and software upgrade, the 2012 version would not need an upgrade.

2. The 2016 version is more expensive than the 2012 version.

3. The 2016 version also incorporates the features of the 2012 version, while the 2012 version only has its unique features.

4 0
4 years ago
Other questions:
  • DOES ANYONE KNOW HOW TO CHAGE THE IP ON A COMPUTER?
    8·1 answer
  • Which of the following was not important in the development of the internet?
    10·2 answers
  • When measuring an unknown voltage with an analog VOM, you should first A. ground the circuit. B. set the switch to the lowest ra
    5·1 answer
  • Which is an example of Raw Input?
    11·1 answer
  • Your mom wants to purchase a computer. She has heard about how the Windows 8 operating system is best-geared for a touch-enabled
    10·2 answers
  • write a c++ program that writes weather data from a file wx_data.txt to a file wx_summary for everyday of the year. also add min
    15·1 answer
  • Who is the prince of math?
    5·2 answers
  • Write a program that asks the user for the name of a text file. The program should display the first 10 lines of the file on the
    6·1 answer
  • Sharing resources.
    14·1 answer
  • A type of attack where the adversary intercepts network packets, modifies them, and inserts them back into the network is called
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!