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
Write a program to randomly fill an array of float of 10 elements (use the rand() function and make sure to use #include ) in ma
Lilit [14]

Answer:

#include <iostream>

#include <stdlib.h>

#include <time.h>

using namespace std;

// array fill and returnig array to the main()

float *arrayFill(float *arr) {

// srand() allows generate new random value everytime the program runs

srand(time(NULL));

for (int i = 0; i < 10; i++)

{

 // array fill with random number between 0 to 100

 arr[i] = (rand() % 100);

}

return arr;

}

// print array

void print(float* arr) {

cout << "Array:  ";

for (int i = 0; i < 10; i++)

{

 cout << arr[i] << "   ";

 

}

}

float maxNum(float* arr) {

float temp = arr[0];

for (int i = 1; i < 10; i++) {

 if (temp < arr[i]) {

  temp = arr[i];

 }

}

return temp;

}

int main() {

// creating dynamic array of elements 10 in heap memory

float *arrPtr = new float[10];

float result = 0;

// calling arrayFill()

arrPtr = arrayFill(arrPtr);

// calling print() to print array

print(arrPtr);

// calling maxNum() to find maximum number in the array

result = maxNum(arrPtr);

cout << "\nmaximum number: " << result;

delete[] arrPtr;

return 0;

}

Explanation:

please read inline comments inside the code section:)

4 0
3 years ago
Which protocol, as a companion protocol to RTP, provides monitoring and reporting for RTP connections?
MrRa [10]
<span>The answer is Real Time Control Protocol (RTCP).   A companion to RTP, the RTCP provides monitoring and reporting for RTP connections.  It resembles the RTP but there are more alternate structures that depend upon the type of the RTCP packet.</span>
4 0
2 years ago
What is the location used by users to configure delegate access on their own mailboxes?
NeX [460]
Inbox? I think if wrong sorry
3 0
3 years ago
Read 2 more answers
Let X and Y be two decision problems. Suppose we know that X reduces to Yin polynomial time. Which of the following statements a
DerKrebs [107]

Answer:

d. If X is NP - complete and Y is in NP then Y is NP - complete.

This can be inferred

Explanation:

The statement d can be inferred, rest of the statements cannot be inferred. The X is in NP complete and it reduces to Y. Y is in NP and then it is NP complete. The Y is not in NP complete as it cannot reduce to X. The statement d is inferred.

4 0
3 years ago
Every time I try to look up anything on my laptop it keeps saying my connection is not priavte what do I do
dangina [55]

You can click "Advanced" and still proceed to the website.


Please mark this answer as the Brainliest! Thank you :)




6 0
3 years ago
Read 2 more answers
Other questions:
  • If a gas gosts 3.60 per gallon how much doe sit cost to drive 500 miles in the city
    5·1 answer
  • 2) Complete the get_num_of_characters() function, which returns the number of characters in the user's string. We encourage you
    11·1 answer
  • Once your hard drive is installed what needs to be done to the drive and what do these two tasks do
    12·1 answer
  • Documents on the web stored on web servers are known as web _____.
    6·1 answer
  • Sarah, a computer user, tells James, a computer technician, that the network she is connected to is running too slowly. Which of
    5·1 answer
  • Place the steps in order to link and place text into the document outline, effectively creating a master document.
    8·1 answer
  • A Raycast returns a float that tells you how far away an Object is
    8·1 answer
  • Transborder data flow (TDF) restricts the type of data that can be captured and transmitted in foreign countries. True or False
    12·1 answer
  • How can you relate the careers in Finance as BSIS students?
    15·1 answer
  • At the heart of every computing device is a(n) _______________, which is usually a single, thin wafer of silicon and tiny transi
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!