total_weight = 0.0
for weight, item in l:
    total_weight += weight
cuml.append((total_weight, item))
return [cuml[bisect.bisect(cuml, random.random() * total_weight)] for x in
    range(n)]
Взвешенный случайный выбор с заменой и без