Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in python please : A friend of yours has written a Python program and they have asked you to help debug it. It is supposed

in python please :

A friend of yours has written a Python program and they have asked you to help debug it. It is supposed to read and analyze a bunch of test scores. Unfortunately this program is not accomplishing all of these tasks.

The program needs to determine the total of all test scores, determine the average, print the sum of all test scores and print the average of all test scores.

Find the 5 bugs in this program. As you find each bug, place a comment in the code explaining what you did to fix the program code. Put the number of the fix in the comment. For example: # Fix 1: Added a call to main

#This program was meant to load a series of test scores into an array.

#Once in the array the program needed to determine the Total of all of the

#scores and the Average. It then needed to print the Total and Average

#to the user. Summer 2018.

def DetermineTotalScores(TestScores):

#declare local variables

Index = int()

OneScore = float()

Total = float()

#Calculate Total

for Index in range(0, len(TestScores)):

OneScore = TestScores[Index]

Total = OneScore + Total

#end for

def DetermineAverage(TotalScore, TestScores):

#declare local variables

NumScores = int()

Average = float()

#determine Total number of scores in test scores array

NumScores = len(TestScores)

#determine Average

Average = TotalScore/NumScores

return Average

def PrintTotal():

#Print out the Total score

print("The Total score is:\t", TotalScore)

def PrintAverage(Average):

#print out the Average

print("The Average score is:\t", format(Average, ',.2f'))

def main():

#declare variables

TestScores = [0] * 5

Average = float()

TotalScore = float()

#filling test scores

TestScores = [85.5, 75.25, 88.0, 90.25, 92.0]

#Determine the Total for all of the scores

TotalScore = DetermineTotalScores()

#Determine Average

Average = DetermineAverage(TotalScore, TestScores)

#Print out Total score and Average

PrintTotal(TotalScore)

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

Step: 3

blur-text-image

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

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

7. It is advisable to do favors for people whenever possible.

Answered: 1 week ago

Question

9. Power and politics can be destructive forces in organizations.

Answered: 1 week ago