Click here to Skip to main content
15,843,727 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
I am using myplotlib and want to sort grades into different categories like [90, 100], [80,90) , [70,80), etc. Is there a function for categorizing a range of values?
Posted
Comments
Sergey Alexandrovich Kryukov 3-Nov-15 14:24pm    
"A function"? How can you imagine that? :-)
—SA

1 solution

You may be best off writing your own function to address the problem. The below example is not a complete solution, but how i would approach the problem and might be a good starting space for you too.

Lets imagine that you are sorting students numerical grades into A, B, C, D, E...

and you have a classList of lists [[studentName, numGrade]]

Python
For eachStudent in classList:
   if numGrade >= 90
       classList[x].append = "A"
   if numGrade <= 90 and >= 80 
       classList[x].append = "B"


....

At the end of of it you should be able to create a list of lists, that has categorized the letter grade of the student to the numerical grade they have earned.
 
Share this answer
 
v2

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