![sonicshon2](/avatars/29011.jpg)
sonicshon2
27.07.2020 •
Computers and Technology
Python: Write a program that generates 8 random scores (between 0 and 100), store them in an array,
finds the best score, and then assigns grades based on the following scheme (use loops
wherever possible):
Grade is A if score >= best – 10
Grade is B if score >= best – 20
Grade is C if score >= best – 30
Grade is D if score >= best – 40
Grade is F otherwise.
Solved
Show answers
More tips
- H Health and Medicine AKDS Vaccination: Ensure Your Child s Safety...
- H Health and Medicine Naskol ko Opasen Ukus Kleshcha i Kak Ego Raspoznat...
- H Health and Medicine 10 Ways to Cleanse Your Colon and Improve Your Health...
- D Dating, Love, Relationships How to Overcome Jealousy: Tips and Tricks...
- H Health and Medicine Angina: Causes, Symptoms, and Treatment...
- C Computers and Internet How to Learn to Type Fast?...
- F Food and Cooking Delight for Gourmets: How to Prepare Liver Pate...
- S Style and Beauty How to braid friendship bracelets?...
- H Health and Medicine Mercury Thermometer Danger: What to do when a thermometer breaks?...
- F Food and Cooking Which Calamari Salad is the Most Delicious?...
Answers on questions: Computers and Technology
- E English PLEASE HELP ME!! Whoever has read chapter 31 of to kill a mockingbird please tell me how that chapter made you feel, what part of the chapter was interesting to...
- C Chemistry Which of the following best describes a wave moving through a medium? A. When energy is transferred, the wave stops, B. The matter making up the medium does not...
- M Mathematics Which statement is true about the equations -3x+4y=12 and -1/3y=1...
- B Biology * ANSWER ASAP * What type of pollution contains tiny particles that remain in the air and may be breathed in by humans? a.) gaseous emissions b.) carbon monoxide...
- M Mathematics Let U = {3, 6, 9, 12, 15, 18, 21, 24} and A = {9, 12, 15, 21}. A...
- M Mathematics A group of students is given a 10 by 10 grid to cut into individual unit squares. The challenge is to create two squares using all of the unit squares. Their teacher...
- M Mathematics The figure below is rotated 270° clockwise about the origin .List the coordinates of the image. 10 9 2 A D B с X -10 9 8 7 6 5 4 3 2 1 2 3 4 5 6 7 8 9 10 -2 3 -6...
- M Mathematics The cost, C dollars, to produce a school yearbook is given by the equation c= 7500 + 8n, where n is the number of yearbooks printed. A. what does each term on the...
- M Mathematics Which is the equation of a line that has a slope of One-half and passes through point (2, –3)?...
- H History Why do you think keynesian ideas appealed to president roosevelt ? Please help....
Ответ:
The program written in python is as follows;
Note that the program makes use of function named checkbest
Lines written bold are comments and are used to replace the explanation section
#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
Ответ:
your answer would be the operating system.