Hello, I have a homework assignment and I just had a couple of questions about it.
Here is the problem directions and the given info for reference,
“There are ten names and five lists of test scores. The correspondence
between the names and the test scores are determined by positions. For example, the test scores for Cindy are 67, 92, 67, 43, 78. Drop the lowest of the five test scores for each student and average the rest and determine the letter grade for that student.”
names = ['April','Bill','Cindy','Dave','Emily', 'Frank','Gene','Hank','Irene','Jeff']
test1 = [35,21,67,45,88, 77,63,96,89,88]
test2 = [11,67,92,35,89, 25,78,94,81,63]
test3 = [94,33,67,34,67, 88,55,99,23,43]
test4 = [27,83,43,67,93, 45,67,77,86,90]
test5 = [43,76,78,45,65, 99,65,65,79,43]
Okay so, I know how to do the problem, but I was wondering if there was a useful method to SIMPLIFY the process. I am writing the code the way he taught us in class, but he also does not mind if we branch out and use other functions. If anyone has any suggestions that would be awesome! If this doesn’t make sense or I need to clarify something just let me know please.
This is my code below… see how I have to repeat the same process for each test score. I will have to do this several times (printing sum, average, and grade) and I would like to learn a more efficient method.
**** Note that each student’s test grades correspond vertically****
print (sum(test1)-min(test1))
print (sum(test2)-min(test2))
print (sum(test3)-min(test3))
print (sum(test4)-min(test4))
print (sum(test5)-min(test5))
print ((sum(test1)-min(test1)) / (len(test1)-1))
print ((sum(test2)-min(test2)) / (len(test2)-1))
print ((sum(test3)-min(test3)) / (len(test3)-1))
print ((sum(test4)-min(test4)) / (len(test4)-1))
print ((sum(test5)-min(test5)) / (len(test5)-1))
which gives the output :
648
624
580
651
615
72.0
69.33333333333333
64.44444444444444
72.33333333333333
68.33333333333333
^^ I will round those later
THANKS!!