Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

To be written in Python 3.x.x SIMPLE program #Accumulators to hold count and run

ID: 3764784 • Letter: T

Question

To be written in Python 3.x.x SIMPLE program

#Accumulators to hold count and running total count = 0 total = 0 #Variables to hold the current highest and lowest values highest = -1000 lowest = 1000 #STEP 1 - Open the data file named prog7Data.txt in read mode #Print a message to let the user know what is happening print("Reading data from file...") #STEP 2 - Read the first line from the file to get things started #STEP 3 - Use a while loop to test if the end of file has been reached while #STEP #4 - Convert the value read from the file to a float #STEP #5 - Add the value to the running total #STEP #6 - Add 1 to the counter #STEP #7 - Check for new low value #STEP #8 - Check for new high value #STEP #9 - Read the next line from the input file #STEP #10 - Close the file #STEP #11 - Print the summary statistics (count, total, average, etc.)

Explanation / Answer

high = -1000.0
low = 1000.0
count = 0
total = 0
file = open('prog7Data.txt','r')
print('Reading data from file...')
for line in file:
   s = float(line)
   high = max(s,high)
   low = min(s,low)
   total += s
   count += 1
print('following are the statistics')
print('highest number is ',high)
print('low number is ',low)
print('total sum is ',total)
print('total numbers are ',count)
print('average is ',(total/count))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote