Hello
I am hoping someone can put me on the right track. The code below includes the assignment question at the beginning. I seem to have been able to calculate average ok, but what I can't seem to do is sort it so it will return a grade for each result. Can you give me some advice to head me in the right direction please. My code is: """Write a program that asks the user to enter 5 sets tests scores. The program should then display the 'letter grade' (A, B, C, D, F) for each test score, and the overall average test schore. Write the following functions in the program: * Calc_average: This function should take five test scores as parameters, and return the average score. *determine_grade; this function should take a single test score as a parameter, and return a letter grade for the test. The letter grade should be on the following grade scale: 90-100: A, 80-89: B, 70-79: C, 60-69: D, <60: F.""" def main(): #Get users first test result test1 = int(raw_input('Enter the score for test 1: ')) #Get users second test result test2 = int(raw_input('Enter the score for test 2: ')) #Get users third test result test3 = int(raw_input('Enter the score for test 3: ')) #Get users forth test result test4 = int(raw_input('Enter the score for test 4: ')) #Get users fifth test result test5 = int(raw_input('Enter the score for test 5: ')) #Get the sum of the test results cal_average = sum(test1, test2, test3, test4, test5)/5 #Display the total of tests print 'Together your tests average is: ', cal_average print 'Your grade is: ', grade # The sum function to total all tests def sum(test1, test2, test3, test4, test5): result = test1 + test2 + test3 + test4 + test5 return result def determine_grade(score): #Determine the grade for each score if score <101 and score >89: score = A elif score <90 and score >79: score = B elif score <80 and score >69: score = C elif score <70 and score >59: score = D else: score = F return score # Call the main function main()
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor