Scientific Computing
Create a file gradeAverages.py
and copy the following code into it:
def getAverages(myList):
# FILL IN CODE TO COMPUTE AVERAGE
return 0
numGrades = input("How many grades? ")
numGrades = int(numGrades)
allGrades = []
for i in range(numGrades):
# FILL IN CODE TO GET OTHER GRADES
nextGrade = 0 # what to put?
gradeAverage = getAverages(allGrades)
print("Your grades are: ", allGrades)
print("The grade average is: ", gradeAverage)
This code aims to get the number of grades that will be input (e.g., 5), and then ask the user to input each score individually (e.g., 100, then 90, then 80, then 98, then 97, pressing enter after each score is input).
It should add all grade scores into a list allGrades
. The function getAverages
should compute the average of all scores in that list and return it.
Complete the program as described and test that it works.
Start HW 6!
Submit your working activity18.py
to Moodle.