I was wondering if there was another way to code At the core of this problem is the easiest way to solve this problem is to read a file and save the values in the list. Where then you'd have:
a = [1,2,3,4,5,6,1,1,1,1]
import statistics
listMode = statistics.mode(a) # median, average, etc...
I was wondering instead of having to save these values in a
(so memory as it can be quite large), whether I could calculate the mode on the fly as I read the file and update a single value everytime I read a new line i.e. incrementally calculate mode,median and average. So that at the end I'd have a = [mode,median,average]
.