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
A network administrator notices that some newly installed Ethernet cabling is carrying corrupt and distorted data signals. The n
MakcuM [25]

A network administrator notices that some newly installed Ethernet cabling is carrying corrupt and distorted data signals. The new cabling was installed in the ceiling close to fluorescent lights and electrical equipment

Two factors may interfere with the copper cabling and result in signal distortion and data corruption are :

EMI

RFI

Explanation:

  • EMI (electromagnetic interference) is the disruption of operation of an electronic device when it is in the vicinity of an electromagnetic field (EM field) in the radio frequency (RF) spectrum that is caused by another electronic device.
  • During EMC testing, radiated emissions measurements are made using a spectrum analyzer and or an EMI receiver and a suitable measuring antenna.
  • EMI (Electromagnetic Interference) is also called RFI (Radio Frequency Interference).
  • Conducted RFI is unwanted high frequencies that ride on the AC wave form. Radiated RFI is emitted through the air. There are many pieces of equipment that can generate RFI, variable frequency drives included.
  • The internal circuits of personal computers generate EM fields in the RF range.
3 0
3 years ago
5. The coordinates of triangle ABC are A(-7, 3), B(3, -7) and C(8. 8)
kati45 [8]

Answer:

b

Explanation:

6 0
3 years ago
Read 2 more answers
Create a program that prints out a list of all the divisors of a number stored in a variable. (If you don’t know what a divisor
UkoKoshka [18]

Answer:

// Program is written in C++ Programming Language

// Comments are used for explanatory purpose

// Program starts here

#include<iostream>

using namespace std;

int main()

{

// Declare integer variable n which serves as the quotient.

int n;

// Prompt to enter any number

cout<<"Enter any integer number: ";

cin>>n;

// Check for divisors using the iteration below

for(int I = 1; I<= n; I++)

{

// Check if current digit is a valid divisor

if(n%I == 0)

{

// Print all divisors

cout<<I<<" ";

}

}

return 0;

}

7 0
3 years ago
What is one pass of a coding sequence called?​
Oksi-84 [34.3K]

Answer:

In computer programming, a one-pass compiler is a compiler that passes through the parts of each compilation unit only once, immediately translating each part into its final machine code. ... This refers to the logical functioning of the compiler, not to the actual reading of the source file once only.

Explanation:

8 0
3 years ago
Read 2 more answers
11. Which one of the following buttons is used for paragraph alignment?<br>​
Luba_88 [7]

Answer:

<em>C</em>

Explanation:

Option <em>A </em>is used for line spacing.

Option <em>B </em>is used for right indent.

Option <em>C</em> is used for right paragraph alignment.

Option <em>D</em> is used for bullet points.

The button used for paragraph alignment would be option <em>C</em>.

3 0
3 years ago
Other questions:
  • Which of the following is a unique feature of Object-oriented programming?
    6·2 answers
  • What additive keeps engines clean by preventing contaminates and deposits from collecting on surfaces? a. Friction modifiers b.
    10·2 answers
  • What natural resource are available on the coast but not somewhereelse
    13·1 answer
  • Why is compression a "hard problem" for computers? Draw on your own experience compressing text with the text compression widget
    12·1 answer
  • The flynn effect best illustrates that the process of intelligence testing requires up-to-date ________
    14·1 answer
  • What is known as networking in the IT field?
    8·1 answer
  • Miley met up with a bunch of her college friends after several years. She told them that she works for the sound department of a
    5·1 answer
  • What is this....... Iam booking train to patna. ​
    13·2 answers
  • It refers to the story or events in which the film revolves.
    13·1 answer
  • Pleaseeeee helpppppppp​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!