Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i'm getting this error in my python program number = int (number) ValueError: invalid literal for int() with base 10: 'Sum:' def main(): # open

i'm getting this error in my python program

number = int (number)
ValueError: invalid literal for int() with base 10: 'Sum:'

def main():
# open the InputNumber.txt file for reading
urFile = open('numbers.txt','r')
# vairable declaration and settinginitial for vairables
sum,max,min,num,average =0,None,None,0,None

# running loop through each numberin InputNumber.txt file
for number in urFile.read().split():
# convert to a numberinto integer instead of string
number = int(number)

# calculate sum of allnumbers
sum += number

# if max and min areNone
if max is None:
max =number
if min is None:
min =number

# find minimumnumber
if number < min:
min =number

# find maximumnumber
if number > max:
max =number

# increment counter by1
num += 1

# calculate the average
totalAverage = float(sum/num)

# display result
print('sum is', sum)
print('max is', max)
print('min is', min)
print('total of values is ', num)
print('average total is'.format(average))

# open numbers.txt in append createmode
outFile = open('numbers.txt')

# write the above datato the file
outFile.write('um is'+str(sum)+'')
outFile.write('max is'+str(max)+'')
outFile.write('min is'+str(min)+'')
outFile.write('total of valuesis'+str(num)+'')
outFile.write('average totalis'.format(average))

# call the main function
main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Design Operation And Evaluation Of Mobile Communications

Authors: Gavriel Salvendy ,June Wei

1st Edition

3030770249, 978-3030770242

More Books

Students also viewed these Programming questions

Question

=+ What about people between the ages of 50 and 65?

Answered: 1 week ago

Question

Statistical regression: Were extreme groups used?

Answered: 1 week ago

Question

Solve the recurrence T(n) = T(n/3) + T(2n/3)

Answered: 1 week ago

Question

Identify the most stable compound:

Answered: 1 week ago

Question

81. Review the building blocks of financial statement analysis.

Answered: 1 week ago

Question

811. How is the equity growth rate computed? What does it measure?

Answered: 1 week ago