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]
2 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]2 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]2 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
Question 11. Assume that you want to copy and paste some range with values and number formats. Which radio button you should sel
Tcecarenko [31]

Answer:

i had the same qustion

Explanation:

8 0
3 years ago
Read 2 more answers
A ____ firewall keeps a record of the state of a connection between an internal computer and an external device and then makes d
Yakvenalex [24]

Answer:

Stateful frame filtering

Explanation:

<h2><u>Fill in the blanks</u></h2>

A <u>Stateful frame filtering </u> keeps a record of the state of a connection between an internal computer and an external device and then makes decisions based on the connection as well as the conditions.

8 0
3 years ago
How would I CAST this variable to a STRING?<br> teeth = 32
maria [59]

Answer:

By using the str() function.

teeth = 32

print(str(teeth))

Explanation:

The str() function returns the string version of the given object.

4 0
3 years ago
What is nasa data speed
Goshia [24]
NASA downloaded data at a rate of 622 megabits per second<span> (Mbps) using a pulsed laser beam. For comparison's sake, Akamai technologies says that the average internet user has a connection speed of </span>3.3 Mbps<span>. In the United States, the average connection speed is </span>8.7 Mbps<span>.</span>
6 0
2 years ago
Keeping in mind the various definitions of operating system, consider whether the operating system should include applications s
svlad2 [7]

Answer:

<em>it</em><em> </em><em>is</em><em> </em><em>a</em><em> </em><em>group</em><em> </em><em>of</em><em> </em><em>Web</em><em> </em><em>pages</em><em> </em>

6 0
3 years ago
Other questions:
  • Americans overwhelmingly support organ and tissue donation.
    5·1 answer
  • The adjustable contact of a potentiometer is placed at the center of its adjustment. If the total resistance is 5 kOhms, what is
    9·1 answer
  • if your instructors teaching style is very different from your learning preference your best choice is to one work on your weake
    10·1 answer
  • Which of the following is most likely to be considered plagiarism? a. Intentionally reporting the results of inaccurate statisti
    11·1 answer
  • What does coding mean​
    10·2 answers
  • How many clients has<br> Accenture engaged globally on blockchain?
    12·1 answer
  • Add Try/Catch error checking To make sure that the user enters valid values in your program. To catch negative values passed to
    9·1 answer
  • Which of the following is an example of data an Earth-observing satellite would collect?
    7·1 answer
  • MLB The Show 17, which simulates professional baseball games, and Madden Football, which simulates professional football games,
    5·1 answer
  • This provides an easy method for workers to use their computers. FAT FAT RAM RAM DOS DOS GUI
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!