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
Where are parameters such boot order, processor voltage, motherboard raid, hardware virtualization support, and overclocking con
ololo11 [35]

This is configured on the BIOS Setup. During computer start-up usually for windows system this can be accessed via pressing on ESC or Function keys on immediate start up.

6 0
2 years ago
What method does a GSM network use to separate data on a channel?
Sergeu [11.5K]

Answer: TDMA(Time division multiple access)

Explanation: Time-division multiple access is the method that is used by GSM(Global system for mobile communication) usually for the separation process of the data.It is a way in which a same frequency is shared by different time slots of signal.It has high flexibility and so thus is helpful for the GSM network and provides easy services of division.It divides the data according to the time period slots in a GSM network.

4 0
2 years ago
True/False
ANEK [815]

Answer:

The following statement is True.

Explanation:

In the given statement, with the help of the point mode, the user can easily and fastly enter the formulas which is more correct and accurate as compared to the formulas enter by using the buttons of the keyboard. In other words, the user can easily and correctly enters the formulas by using the Point method. So, that's why the following statement is correct.

4 0
3 years ago
Gold is not more useful than iron. (Rewrite in positive form by replacing the comparative adjective)​
Sonja [21]

Answer:

Gold is more useful than iron

5 0
3 years ago
When data is being prepared for transmission onto the network, it is broken into small pieces and a header and trailer are added
Archy [21]

Answer:

The correct answer to the following question will be "Encapsulation".

Explanation:

  • Encapsulation relates to the pooling of data with techniques used by the database or the limitation of immediate access to many of the elements of the entity.
  • As data is being processed for transfer to the network, it's split into tiny pieces and a trailer and header are attached to each piece to help determine it.
  • It is a method of shielding data facts and preserving the object's data and actions from abuse by certain objects.

Therefore, Encapsulation is the right answer.

8 0
3 years ago
Other questions:
  • what is a massive online storage that allows for access by any Internet connected device running a web browser and is used for l
    7·1 answer
  • Which of these symbols is a special character that is accessible only from the Symbol dialog box? A. © B. + C. é D.
    13·2 answers
  • Name a computer programme that designers are likely to use to create a leaflet advertising their new product
    15·1 answer
  • The Active Directory Users and Computers tool can be used to:______.
    11·1 answer
  • Janet manages the security of the database servers at the mortgage company where she works. The servers are Windows Server 2016;
    15·1 answer
  • Write a function to sum the following series:
    8·1 answer
  • A(n) _____ measures the ability to juggle a variety of demands, as in a manager's job where the candidate is presented with simu
    8·1 answer
  • Evolution of computers
    13·2 answers
  • What are the data type(s) will be used to declare the variable(s) needed to
    9·1 answer
  • 5 differences between a regular mouse and a gaming mouse​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!