Answer:
<em>The program written in python is as follows;</em>
<em>Note that the program makes use of function named checkbest</em>
<em>Lines written bold are comments and are used to replace the explanation section</em>
<em></em>
#Program starts here
#This line imports the random module into the program
import random
#This line defines the function checkbest, with 2 parameters
def checkbest(score,best):
#The following if condition implements the condition as stated in the
#program requirement
if score >= best- 10:
grade = "A"
elif score >= best - 20:
grade = "B"
elif score>= best - 30:
grade = "C"
elif score >= best - 40:
grade = "D"
else:
grade = "F"
#This line returns the letter grade depending on the above
#conditions
return "Grade: "+grade
#The main method starts here
#This line declares an empty list
array = []
#This line iterates from 1 to 8
for i in range(1,9):
#This line generates a random integer between 0 and 100 (inclusive)
score = random.randint(0,100)
#This line inserts the generated score in the list
array.append(score)
#This line sorts the list in ascending order
array.sort()
#This line gets the best score
best = array[7]
#This line iterates through the elements of the list
for i in range(0,8):
#This line prints the current score
print("Score: "+str(array[i]))
#This line calls the function to print the corresponding letter grade
print(checkbest(array[i], best))
#This line prints an empty line
print(" ")
#The program ends here