My problem has to do with statistics and the creation of a dynamic number of variables in Python.
I have a data set of values from 0-100.
If the user enters 5 upper limits, 20, 40, 60, 80, 100, the program should sort the values into 5 classes, list1, list2, list3, list4, list5. If the user enters 4 upper limits, 25, 50, 75, 100, the program should sort the values into 4 classes, list1, list2, list3, list4.
Then, I need to find the average for each list, eg, list1Average, list2Average, list3Average, list4Average and store these average values in another list, averagesList.
Finally, I need to subtract the average for each respective class (list1Average, list2Average, list3Average, list4Average) from each value in the dataset. i.e. subtract list1Average from each value in list1, subtract list2Average from each value in list2, etc, and store those derived values in yet another list, classVarianceList.
I've managed to do all of this quite easily, but only when the number of class upper limits is static (I can just do class1.append(i), class2.append(i), etc). But now I'm going insane trying to figure out how to do this when the number of classes can be determined by the user. The main issue is the creation of a dynamic number of variables (lists) to store values and run calculations upon.
I've also read up on Python's dictionaries (because everyone says to use dictionaries to dynamically create variables), and while I get that it ties a key to a value, I just can't for the life of me, figure out how to incorporate this into what I want to do.
Thank you very much for any help!