1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Olegator [25]
3 years ago
8

Python: Write a program that generates 8 random scores (between 0 and 100), store them in an array,

Computers and Technology
1 answer:
maksim [4K]3 years ago
6 0

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

You might be interested in
Is a router on the local network that is used to deliver packets to a remote network?
Nesterboy [21]
I believe so, if im right
7 0
3 years ago
You type. The word "weather" when you ment "whether" when will the writer or word flag this as a misspelling or a grammar proble
xxTIMURxx [149]
Most likely depends on the situation
8 0
3 years ago
Select each of the strategies you can use to be more efficient when using the Internet. using tabs creating tables creating book
xeze [42]
Using tabs creating tables creating bookmarks &
<span>deleting bookmarks you are no longer using organizing bookmarks into folders
</span>
<span />
6 0
3 years ago
Read 2 more answers
A line beginning with a # will be transmitted to the programmer’s social media feed.
zhenek [66]

Answer:

True?

Explanation:

4 0
3 years ago
Read 2 more answers
Which of the following can you use to attach external hardware devices to a computer?
Genrish500 [490]

The answer is c that what a lot of people use☻

5 0
3 years ago
Read 2 more answers
Other questions:
  • Using the expected format, of putting key information where the reader can’t find it, is an example of?
    8·2 answers
  • Which statement about the Paste Link option is true? A)Even if the source file (spreadsheet) is deleted, the data updates automa
    11·1 answer
  • Does functionality provided by the app play an important role in a decision to
    13·1 answer
  • Does the game cooking fever use data?
    10·1 answer
  • The growing network of physical objects that will have sensors connected to the Internet is referred to as the ________.
    13·1 answer
  • PLEASE HELP
    5·1 answer
  • .<br>1.<br>CPU<br>f. ALU<br>. CU<br>h. CRT<br>g. LED<br>​
    15·1 answer
  • How was the Big Ben project similar to the investigation you conducted in class to determine if the table was vibrating? How is
    7·1 answer
  • PLEASE HELP I WILL GIVE BRAINLIEST!!!!
    7·2 answers
  • Catherine, a web designer, has created new content for a client's website. In order to update the company website, she needs to
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!