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
mixer [17]
3 years ago
11

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 and stores the largest number read in a variable named maxvalue.
Computers and Technology
2 answers:
prisoha [69]3 years ago
6 0

In Python, assume that a file containing a series of integers is named numbers.txt and exist on the computer's disk. Write a program that reads the entire numbers store in the file and calculates their total.

Here is what I have written but it does not run:  

def. main():

   out file=open('numbers.txt','r')

   temp=outfile.readline()

   total=0

   while temp!='':

       t=int(temp)

       total=total+i

       temp=outfile.readline()

       outfile.close()

       print('Total sum is:',total)

main()

Text file is a file named numbers.txt with the numbers 1-50 in it

Learn more:

  • The sum of three consecutive integers is 186. what are the integers

        brainly.com/question/1768254

Keywords: python, integers, computer, numbers, program

storchak [24]3 years ago
3 0

To find the maximum value from a list of single positive integers of a file following procedure is used:

First open the file and initialize the maxvalue variable. Now, begin the for loop that will compare the maxvalue variable with the value stored in the file. If the value of maxvalue variable is less than the stored value of the file then store it in maxvalue variable otherwise not store it. The comparison will continue till the last value of the file and finally display the maximum value.

Further explanation:

The python code to calculate the maximum value from a file is as shown below:

Code:

#First open the file  in the read mode

file = open('numbers.txt', 'r');

#Initialize the variable

maxvalue=0

#Begin the for loop.

for line in file:

#Compare the values of text file from maxvalue variable and find the maximum value

if maxvalue <= int (line):

#Store the maximum value in the variable maxvalue.

maxvalue = int (line)

#Display the maximum value of the numbers.txt file.

print ('maxvalue is:',maxvalue)

The content of the text file is as shown below:

<u>Text file "numbers.txt"</u>

3

6

8

1

6

9

4

7

2

Output:

maxvalue is : 9

Learn more:

1. How does coding work on computers?  brainly.com/question/2257971

2. Prediction accuracy of a neural network depends on _______________ and ______________. brainly.com/question/10599832  

Answer details:

Grade: College Engineering

Subject: Computer Science

Chapter: Python Programming

Keyword:

python, input, output, programming, statements,  char, int, variables, maxvalue, open, file, loop, text file, line, numbers

You might be interested in
In the lungs,blood picks up carbon dioxide and releases oxygen true or false
Maksim231197 [3]

Answer:

false

Explanation:

plants do that, they absorb carbon dioxide and then they create oxygen, then humans breathe the oxygen and makes CB

8 0
3 years ago
A firm uses BitLocker for volume encryption. Normally, BitLocker performs its task well. However, an administrator was recently
raketka [301]

Answer:

The BitLocker keys were compromised

Explanation:

Given that the act of decrypting and encrypting all over is a means of troubleshooting the issue of security in computing operations. Hence, when an administrator is forced to decrypt and encrypt the entire volume, the main reason for such action can be as a result of "BitLocker keys were compromised."

Hence, the right answer, in this case, is that "The BitLocker keys were compromised."

3 0
3 years ago
You work as a Network Administrator for McNeil Inc. The company has a Linux-based network. You have just created a directory nam
timofeeve [1]

Answer:

E.

Explanation:

Based on the information provided within the question it can be said that the most likely cause is that David does not have the write permission on the directory. This permission basically grants the individual the ability to make changes to a certain file or directory. Therefore if David does not have write permission it would explain why he is unable to save his reports in that directory.

8 0
3 years ago
"Rights and duties are two sides of the same coin." Explain with examples​
telo118 [61]

Answer:

Find the explanation below.

Explanation:

Rights are privileges that citizens or members of a community are entitled to by law. Duties are the responsibilities required of them. These two work together and are dependent on each other. Performing our duties help to safeguard our rights.

For example, the law specifies the right to life for people. This is an entitlement that should be respected by the individual and others around him. It is therefore the duty of the individual and others to respect this right to life and never compromise it in any way.

The law allows the right to free speech. It is also our duty to be patriotic and this would prevent compromising the right to free speech by saying unpatriotic things that can cause political tensions.

3 0
3 years ago
If a destructive program is running that might be destroying evidence what should be done
Vikentia [17]
The choices can be found elsewhere and as follows:
a. perform an immediate full backup
b. attempt to end the process
c. pull the power cable
d. record the destruction using a video capture of the screen

I think the correct answer is option a. If a destructive program is running that might be destroying evidence, then perform an immediate full backup. 
3 0
3 years ago
Other questions:
  • Your computer is once again out of hard drive and you want to see which folders are consuming the most space on your drive. Whic
    15·1 answer
  • When a user inserts a PivotTable, where will it be inserted?
    15·1 answer
  • Who wants to join my zoom after school 23456+4567
    15·1 answer
  • A DBMS makes the: a. relational database available for different analytical views. b. physical database available for different
    12·1 answer
  • What do green squiggly lines under text indicate?
    14·1 answer
  • a. Create an Abstract class called Vehicle with abstract methods accelerate, stop, and gas, &amp; data of your choice (5 marks)
    12·1 answer
  • What one main difference between social media and traditional media such as television?
    12·2 answers
  • When using a small mic that attaches to your interview subject, where should you place that mic and why?
    5·1 answer
  • A database admin uses a SHOW statement to retrieve information about objects in a database. This information is contained in a _
    10·1 answer
  • TensorFlow and Pytorch are examples of which type of machine learning platform?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!