Вы можете попробовать это:
from random import random
from statistics import median
masses = [ random()*10 for _ in range(150) ]
intervals = [ (0.2,0.5),(0.5,1.2) ]
for (low,high) in intervals:
inRange = [ mass for mass in masses if mass >= low and mass < high ]
print("(",low,",",high,") count=",len(inRange),"median=",median(inRange), "range=", min(inRange),"-",max(inRange))