Click here to Skip to main content
15,747,845 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Anonymised scores (out of 60) for an examination are stored in a NumPy array. Write:

A function that takes a NumPy array of the raw scores and returns the scores as percentages, sorted from lowest to highest (try using scores.sort(), where scores is a NumPy array holding the scores).

A function that returns the maximum, minimum and mean of the raw scores as a dictionary with the keys 'min', 'max' and 'mean'. Use the NumPy array functions min(), max() and mean() to do the computation, e.g. max = scores.max().

Design your function for the min, max and mean to optionally exclude the highest and lowest scores from the computation of the min, max and mean.

Hint: sort the array of scores and use array slicing to exclude the first and the last entries.

Use the scores

scores = np.array([58.0, 35.0, 24.0, 42, 7.8])
to test your functions.

What I have tried:

def to_percentage_and_sort(scores):
    raise NotImplementedError()

def statistics(scores, exclude=False):
    raise NotImplementedError()
Updated 5-Nov-20 2:12am

1 solution


That is the part that you are expected to write. This site does not provide code to order. However, if you have a specific question then please ask it and people will try to help you.
Share this answer
wendy monyee 5-Nov-20 12:40pm    
I dont know what to do :-( Please help me
Richard MacCutchan 5-Nov-20 12:51pm    
Start by learning Python, or studying your course notes. If you cannot understand either of those then talk to your teacher.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900