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
Alpha Technologies, a newly established company, wants to share information about its work with people all over the world. Which
melisa1 [442]
<span>Option A, Web Server, because it is a type of HTTP server used to direct web pages and blogs, as a method of transmitting information through a web platform for personal or business use, to publicize a business or an organization. In this way, information about the company is transmitted through web pages that use this type of server.</span>
8 0
3 years ago
Where are the values the computer is directly working with at a particular moment in time stored?
pav-90 [236]

On the CPU register (?) The CPU registers are registers with small amounts of high-speed memory contained within the CPU. They are used by the processor to store small amounts of data that are needed during processing

Hope this helps and that you have a good day

4 0
3 years ago
Describe accessibility in Windows 7 ​
satela [25.4K]

Answer:

Accessibility is the epitome of usability and was a key tenet throughout the engineering of Windows 7. ... Windows 7 includes accessibility options and programs that make it easier to see, hear, and use your computer including ways to personalize your computers and use keyboard shortcuts.

7 0
3 years ago
A database planner names a field “Organic ingredients_3”. Why would this name Create possible problems in programming?
o-na [289]

Answer:

I think the answer is 2.

hope it will help you

4 0
3 years ago
Read 2 more answers
Use the conversion table below to help you answer the question.
andrew-mc [135]
Correct answer is 11
7 0
3 years ago
Other questions:
  • Technological progress has reduced the cost of manufacturing mp3 players. what happens if demand is unchanged?
    9·1 answer
  • Write a method called all Less that accepts two arrays of integers and returns true if each element in the first array is less t
    12·1 answer
  • Linda is training to become a certified network design expert and consultant. While researching about the process of cellular ra
    12·1 answer
  • Write a program that reads in characters from standard input and outputs the number of times it sees an 'a' followed by the lett
    11·1 answer
  • During which part of geologic time did photosynthesis evolve?
    15·2 answers
  • The total magnification of a specimen viewed under a compound light microscope is determined by:
    6·2 answers
  • When measuring processor speed,a megahertz is much faster than a gigahertz.true or fals
    12·1 answer
  • Which is a feature of audio editing software?
    11·2 answers
  • How does our behavior change when we know we're being watched?
    14·1 answer
  • Advantages and disadvantages of a watch tower​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!