Created
March 4, 2018 19:46
-
-
Save azbones/95f256070d306003cc04cc87c90e6e48 to your computer and use it in GitHub Desktop.
randomly assign list of students to a set number of groups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# randomly assign list of students to a set number of groups | |
import random | |
def partition(lst, n): | |
division = len(lst) / float(n) | |
groups = [lst[int(round(division * i)): int(round(division * (i + 1)))] for i in range(n) ] | |
return groups | |
students = [] | |
random.shuffle(students) | |
groups = partition(students,4) | |
print(groups) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment