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
ipn [44]
3 years ago
15

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:
andreev551 [17]3 years ago
8 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

Afina-wow [57]3 years ago
5 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

You might be interested in
___ is the most important variable that is measured and controlled in a commercial hvac system.
Pavel [41]

The parameter being monitored and controlled is the controlled variable. The dry-bulb temperature of the air leaving the cooling coil is the controllable variable in this particular instance. The sensor assesses the state of the controlled variable and provides the controller with an input signal.

<h3>What is a HVAC ?</h3>

The employment of various technologies for heating, ventilation, and air conditioning is done to regulate the temperature, humidity, and cleanliness of the air in a closed environment. Its objective is to provide adequate indoor air quality and thermal comfort.

  • To cool or heat a building, the main unit of a ducted system forces air via a network of air ducts. On the other hand, ductless systems don't have air ducts and employ different techniques to spread cleaned air across a room.

Learn more about HVAC system here:

brainly.com/question/20264838

#SPJ4

6 0
2 years ago
What is the purpose of using specialized supply chain software?
weeeeeb [17]

Answer:

The purpose of supply chain management is

On the most basic level, the purpose of supply chain management is to make inventory readily available in customer facing positions to fulfill demand. ... Supply chain partners must work together to maximize resource productivity, develop standardized processes, eliminate duplicate efforts, and minimize inventory levels

Explanation:

4 0
3 years ago
A computer with a domain name is called a what
Irina18 [472]
A domain refers to a group of computers that are part of a network and share network resources, like your home<span> computers all linked together sharing a printer. The user logs in to the domain and gains access to the resources. Several systems may be involved. The computer itself is referred to as a server.</span>
6 0
3 years ago
Read 2 more answers
Start
Crank

Answer:

N=5  key task decision start and end

Explanation:

8 0
3 years ago
If you were a developer of software, what kind of software package would you develop? why ?​
Goshia [24]

Answer:

Software that would help my grandparents in the North end much money and help stop post harvest loss due to inadequate weather information Climate change etc

Explanation:

The app willbe able to tellif a soil is suitable forCropsthrough my othertechnologiesthat willcome with app it will alsodetect the whetherpattern accuratelyprovide securityin the farmand help farmers selltheir products online

7 0
3 years ago
Other questions:
  • One form of Intrusion Detection System (IDS) starts operation by generating an alert for every action. Over time, the administra
    5·1 answer
  • COMPUTER ORGANIZATION &amp; ARCHITECTURE I<br>please help need the correct answers to all
    6·1 answer
  • Who wants to talk? I am willing to talk to anyone! I AM SO BORED!!
    13·2 answers
  • The site is not allowing me to purchase the subscription. Please help?
    12·1 answer
  • What is the term given to the controls that let you interact with an operating system?
    11·1 answer
  • Write down a pair of integers whose sum is​ 0
    5·1 answer
  • Compute series multiplier resistors RM = 100Ω:
    8·1 answer
  • Create five circles like the Olympic Rings. fill them with the colors given below
    8·1 answer
  • Differentiate between a software package and integrated software and why users would choose one over the other.
    11·1 answer
  • ......................... and ....................... are two ways to define the text in Inkscape.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!