samedi 20 juin 2015

Using random function to find "cut off" values on python

I need help with this problem and I think the major reason I don't know how to do it is because I don't really understand what it is asking for.

The problem is asking to write a program that will find the curve of a class. It has to find the "cut off" values for A,B,C and D. 40% of the class will receive an A, as well as a B(40%), 10% will receive a C and the remaining 10% will get a D. The grades have to be generated randomly between 20 - 100 and the number of student has to be an input. a tuple has to be returned with the cut off values of A,B,C and D.

It also gives me the hint to use list.sort() and min(list)

I honestly don't really get what this is asking for, so far I have this but I am not sure what I am doing.

import random
def Cutoffgrade():
    students=float(input('How many students are in the class?'))
    grades=list(range(20,101))
    list.sort(grades)
    Astudents=students*0.4
    Bstudents=students*0.4
    Cstudents=students*0.1
    Dstudents=students*0.1

I also have this other function I did which I know is something similar to what I have to do, but I just don't get this problem. Here is the other function I did for a different problem that is somewhat asking for a random list as well:

def createlist(v1,v2):
    random.randint(v1,v2)
    random.randrange(v1,v2)
    numlist=[]
    for i in range(5):
        n=random.randrange(v1,v2)
        numlist.append(n)
    print(numlist)

So I have been trying to transform this function into what I would need for the new problem but don't know how.




Aucun commentaire:

Enregistrer un commentaire