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
To create a formula, click the cell where you want to add the formula and press the _____ key.
Ipatiy [6.2K]
C........is the answer
4 0
3 years ago
Read 2 more answers
What is the check digit for the following original product number: 140501941 ? *
Natasha_Volkova [10]

Explanation:

I think it is 7, but I could be wrong..... sorry

8 0
3 years ago
Read 2 more answers
Acess labeling windows​
Debora [2.8K]

Answer:

I got the same thing

Explanation:

8 0
3 years ago
Aika has several labeled folders for different parts of his research. What is the MOST likely reason he does this? He wants to m
kobusy [5.1K]

Answer:

<u>He wants to easily and quickly find specific bits of research that cover certain topics.</u>

<u>Explanation:</u>

Remember, a research work typically has these 6 (six) components:

  • The Abstract.
  • Introduction
  • Methodology
  • Results
  • Discussion
  • References.

Thus, Aika's decision to label several folders for different parts of his research would make it easier and quicker for him to find specific bits of research that cover certain topics, instead of spending time looking for topics.

4 0
3 years ago
How many wires are in a standard Cat 6 cable?
Lynna [10]
I believe it is 8

Hope this helps
5 0
2 years ago
Read 2 more answers
Other questions:
  • A method in a class that modifies information about an object is called a/an ____ method.
    14·1 answer
  • Software that interprets commands from the keyboard and mouse is also known as the ​
    7·1 answer
  • Hybrid processors that can process 32 bits or 64 bits are known by what term?
    8·1 answer
  • What is the IEEE standard for the Wi-Fi Protected Access 2 (WPA2) security protocol?
    6·1 answer
  • Technician A says you should measure the parasitic load immediately after the vehicle is turned off. Technician B says you shoul
    10·1 answer
  • Which of the following describes the function of a web browser?
    11·1 answer
  • one data is in memory the computer interpets and executeinstructions to process the data into informationA. TrueB. False
    8·1 answer
  • Which is a circuit board located behind an LCD screen on a laptop?
    7·1 answer
  • Why is there no ide length or timing for study breaks?​
    12·1 answer
  • Explain the different features available in Print command?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!