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
Serga [27]
3 years ago
12

A file named numbers.txt contains an unknown number of lines, each consisting of a single integer. Write some code that computes

the sum of all these integers, and stores this sum in a variable name sum.
Computers and Technology
1 answer:
Schach [20]3 years ago
3 0

Answer:

The code is given below with necessary comments for understanding

Explanation:

#Open the input file.

infile = open("numbers.txt", "r")

#Declare and initialize the required variable sum

#to store the sum of integers read from the file.

sum = 0

#Declare and intialize a variable to store the current

#number read from the file in the integer form.

curNum = 0

#Traverse the input file using for loop.

for curLine in infile:

   #Assign the number read from the file to the

   #variable curNum in the integr form.

   curNum = int(curLine)

   #Add the numbers read from the file to the

   #variable sum to get the sum of all the

   #numbers read from the file.

   sum += curNum

# Display the value of the variable runsum.

print(sum)

You might be interested in
When talking about the physical elements of the internet, the term redundancy refers to:?
Sphinxa [80]
It refers to the physical elements of the internet
6 0
3 years ago
Uses of prototype and who made the prototype<br>​
myrzilka [38]

Answer:

A prototype is an early sample, model, or release of a product built to test a concept or process. It is a term used in a variety of contexts, including semantics, design, electronics, and software programming. A prototype is generally used to evaluate a new design to enhance precision by system analysts and users.

Explanation: The place that made prototype was Radical Entertainment.

Hoped this helped.

3 0
3 years ago
Subcribe to me for brainly my YT is KeepUsweatin
Flura [38]

Answer:

Ok got you. Will do so. Mine is Phantom Pac.

5 0
3 years ago
To display the size of your backup file, you can use the Windows program called: Windows Explorer Scan disk Defrag Windows Acces
Nitella [24]
Windows Explorer scan disk
7 0
3 years ago
The volume of a sphere is 4/3πr3, where π has the value of "pi". Write a function called print_volume (r) that takes an argument
Marizza181 [45]

Answer:

In Python:

def print_volume (r):

   volume = 4/3 * 3.142*r**3

   print(volume)

print_volume(7)

print_volume(14)

print_volume(22)

Explanation:

This defines the function and takes radius r as the parameter

def print_volume (r):

This calculates the volume

   volume = 4/3 * 3.142*r**3

This prints the volume

   print(volume)

The next three lines call the function with different values

<em>print_volume(7)</em>

<em>print_volume(14)</em>

<em>print_volume(22)</em>

6 0
3 years ago
Other questions:
  • When using the wait and signal operations, ____ sets the process's process control block to the blocked state and links it to th
    12·1 answer
  • Why are prepositions, conjunctions, and pronouns usually considered poor choices to use as key words?
    5·2 answers
  • Hi Im really a girl and i want to know how to change my username without having to make a new account?
    9·2 answers
  • A high-angle shot is the same thing as a bird’s-eye shot. True False
    11·2 answers
  • How would improving the nutritional health of an entire community impact the overall physical, emotional, and financial health o
    14·1 answer
  • The local city youth league needs a database system to help track children that sign up to play soccer. Data needs to be kept on
    10·2 answers
  • Hey, how is everyone????????????????????????????????
    8·2 answers
  • Describe the major elements and issues with system prototyping​
    7·1 answer
  • HURRRY WILLL GIVE BRAINLIST!!!!!!
    12·1 answer
  • Which of the following was the first computer-animated film to win animated film to win an academy award?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!