Write a Python program that takes 7 inputs and appends them to a list (aGrades).
ID: 3804121 • Letter: W
Question
Write a Python program that takes 7 inputs and appends them to a list (aGrades).
Use the input function to enter grades.
The final exam will be the last item in the list.
Calculate the number of exams as the length of the list minus one assign exam count to len(aGrades)-1.
Here we will introduce the function sum() to the class.
The Total Points will be equal to the sum of the list minus the final exam.
Assign Total Points to sum(aGrades)- aGrades[lastitemIndex].
Compute the Test Average to be equal to the Total Points divided by the length of the list minus one.
Assign Test Average to Total Points / len(aGrades)-1
The final average will be equal to 60% of the test average plus 40% of the Final Exam.
Assign Final Average to Test Average *.6 + Final Exam * .4
Display the grades list, test average and the final average on separate lines.
I need this code without using loops.
Explanation / Answer
def getGrades(aGrades, n):
if n == 0:
return
else:
grades = int(input("Enter grade: "))
aGrades.append(grades)
getGrades(aGrades, n-1)
aGrades = []
getGrades(aGrades, 7)
numberOfExams = len(aGrades) - 1
totalPoints = sum(aGrades) - aGrades[-1]
testAverage = float(totalPoints)/numberOfExams
finalAverage = .6*testAverage + .4*aGrades[-1]
print "Grades List " + str(aGrades)
print "Test average: " + str(testAverage)
print "Final average " + str(finalAverage)
'''
Sample run
$ python main.py
Enter grade: 80
Enter grade: 90
Enter grade: 80
Enter grade: 90
Enter grade: 70
Enter grade: 100
Enter grade: 100
Grades List [80, 90, 80, 90, 70, 100, 100]
Test average: 85.0
Final average 91.0
# link for code https://goo.gl/6O5eV6
'''
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.