<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://teaching.healthtech.dtu.dk/22113/index.php?action=history&amp;feed=atom&amp;title=Example_code_-_Comprehension</id>
	<title>Example code - Comprehension - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://teaching.healthtech.dtu.dk/22113/index.php?action=history&amp;feed=atom&amp;title=Example_code_-_Comprehension"/>
	<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk/22113/index.php?title=Example_code_-_Comprehension&amp;action=history"/>
	<updated>2026-04-03T13:37:59Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://teaching.healthtech.dtu.dk/22113/index.php?title=Example_code_-_Comprehension&amp;diff=32&amp;oldid=prev</id>
		<title>WikiSysop: Created page with &quot;__NOTOC__ == Files used in example == [http://teaching.healthtech.dtu.dk/material/22113/TA_list.txt TA_list.txt]&lt;br&gt; [http://teaching.healthtech.dtu.dk/material/22113/student_list.txt student_list.txt]&lt;br&gt;  == Assigning students to TA&#039;s, Take 2 == After having used the original program a few times, see Example code - Data structures, I got dissatisfied with it - the randomness did not ensure even distribution of students to the various TA&#039;s. The TA&#039;s got the right nu...&quot;</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk/22113/index.php?title=Example_code_-_Comprehension&amp;diff=32&amp;oldid=prev"/>
		<updated>2024-03-06T13:59:43Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;__NOTOC__ == Files used in example == [http://teaching.healthtech.dtu.dk/material/22113/TA_list.txt TA_list.txt]&amp;lt;br&amp;gt; [http://teaching.healthtech.dtu.dk/material/22113/student_list.txt student_list.txt]&amp;lt;br&amp;gt;  == Assigning students to TA&amp;#039;s, Take 2 == After having used the original program a few times, see &lt;a href=&quot;/22113/index.php/Example_code_-_Data_structures&quot; title=&quot;Example code - Data structures&quot;&gt;Example code - Data structures&lt;/a&gt;, I got dissatisfied with it - the randomness did not ensure even distribution of students to the various TA&amp;#039;s. The TA&amp;#039;s got the right nu...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__NOTOC__&lt;br /&gt;
== Files used in example ==&lt;br /&gt;
[http://teaching.healthtech.dtu.dk/material/22113/TA_list.txt TA_list.txt]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://teaching.healthtech.dtu.dk/material/22113/student_list.txt student_list.txt]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Assigning students to TA&amp;#039;s, Take 2 ==&lt;br /&gt;
After having used the original program a few times, see [[Example code - Data structures]], I got dissatisfied with it - the randomness did not ensure even distribution of students to the various TA&amp;#039;s. The TA&amp;#039;s got the right number of students but a TA could get the same student several times in a row.&lt;br /&gt;
&lt;br /&gt;
To address this issue, I rewrote the program (in better accord with the teaching), keeping some of the original ideas and data structures. A main idea is to have a database of which TA&amp;#039;s have graded which students. By &amp;#039;remembering&amp;#039; the previous distributions, you can spread the students more evenly on the TA&amp;#039;s. This is simply done by creating an extra file (tab separated) with content like:&lt;br /&gt;
&lt;br /&gt;
 TA 1	Student A	3&lt;br /&gt;
 TA 1	Student B	2&lt;br /&gt;
 TA 1	Student C	2&lt;br /&gt;
 TA 1	Student D	3&lt;br /&gt;
 TA 1	Student E	2&lt;br /&gt;
 TA 2	Student A	3&lt;br /&gt;
 TA 2	Student B	3&lt;br /&gt;
 TA 2	Student C	2&lt;br /&gt;
 TA 2	Student D	2&lt;br /&gt;
 TA 2	Student E	2&lt;br /&gt;
 etc.&lt;br /&gt;
&lt;br /&gt;
The number is the times a TA has graded a student.&lt;br /&gt;
&lt;br /&gt;
=== Explanation of the idea: ===&lt;br /&gt;
First the database is loaded from file into a dict of dicts data structure (called base). If no database exists, the data strucure is just initialised with 0.&lt;br /&gt;
The student list and TA list is stil shuffled for the same reasons as last time.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Pseudo code&lt;br /&gt;
Iterating through the list of students:&lt;br /&gt;
  First find a list of available TA&amp;#039;s - those who&amp;#039;s quota is not filled yet.&lt;br /&gt;
  Of those TA&amp;#039;s find the one(s) who have the fewest students assigned - to spread the load evenly.&lt;br /&gt;
  Of those TA&amp;#039;s find the one(s) who have had that student the least adjusted according the average.&lt;br /&gt;
  Of those TA&amp;#039;s assign the student to a random TA.&lt;br /&gt;
Update and save the database with the new assignments.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;quot;who have had that student the least adjusted according the average&amp;quot; requires some more explanation. Since TA&amp;#039;s have different quotas, then a TA with a small quota will always have had a student fewer times than one with a large quota. In order to not automatically select a &amp;quot;small&amp;quot; TA, then a TA&amp;#039;s median for all students is subtracted from the number of times this student has been assigned to the TA. The result is a number, which the lower it is, the more under-assigned the student has been to that TA.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/python3&lt;br /&gt;
import sys&lt;br /&gt;
import random&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def usage(message=&amp;#039;&amp;#039;):&lt;br /&gt;
    &amp;#039;&amp;#039;&amp;#039;A usage message to be displayed when the user gives faulty input&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
    if message != &amp;#039;&amp;#039;:&lt;br /&gt;
        print(message)&lt;br /&gt;
    print(&amp;quot;Usage: assign_TA.py [&amp;lt;file TA list&amp;gt; &amp;lt;file student list&amp;gt; &amp;lt;database file&amp;gt;]&amp;quot;)&lt;br /&gt;
    print(&amp;quot;The list of TAs may contain a maximum of students to assign to the particular TA.&amp;quot;)&lt;br /&gt;
    print(&amp;quot;It must come after the TA&amp;#039;s name whitespace separated.&amp;quot;)&lt;br /&gt;
    print(&amp;quot;Both TA and student lists can have a # as first char - ignoring the person.&amp;quot;)&lt;br /&gt;
    print(&amp;quot;The standard filenames are TA_list.txt, student_list.txt and database.txt&amp;quot;)&lt;br /&gt;
    print(&amp;quot;The database is for keeping track of assignments, so they are shared equally.&amp;quot;)&lt;br /&gt;
    print(&amp;quot;The database is reset by deleting it. Do it once every season.&amp;quot;)&lt;br /&gt;
    sys.exit(1)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#display help if requested or run without arguments&lt;br /&gt;
if len(sys.argv) == 1:&lt;br /&gt;
    TA_file = &amp;#039;TA_list.txt&amp;#039;&lt;br /&gt;
    student_file = &amp;#039;student_list.txt&amp;#039;&lt;br /&gt;
    database_file = &amp;#039;database.txt&amp;#039;&lt;br /&gt;
elif sys.argv[1] in (&amp;#039;-h&amp;#039;, &amp;#039;--help&amp;#039;, &amp;#039;-?&amp;#039;):&lt;br /&gt;
    usage()&lt;br /&gt;
elif len(sys.argv) == 4:&lt;br /&gt;
    TA_file = sys.argv[1]&lt;br /&gt;
    student_file = sys.argv[2]&lt;br /&gt;
    database_file = sys.argv[3]&lt;br /&gt;
else:&lt;br /&gt;
    usage()&lt;br /&gt;
&lt;br /&gt;
# Read TA list&lt;br /&gt;
TA_dict = dict()&lt;br /&gt;
TA_index = list()&lt;br /&gt;
infile = open(TA_file, &amp;#039;r&amp;#039;)&lt;br /&gt;
for line in infile:&lt;br /&gt;
    tmp = line.split()&lt;br /&gt;
    if len(tmp) == 0 or tmp[0].startswith(&amp;#039;#&amp;#039;):&lt;br /&gt;
        continue&lt;br /&gt;
    #if there is a second column this is the max value of students for that TA&lt;br /&gt;
    maximum = 20&lt;br /&gt;
    try:&lt;br /&gt;
        maximum = int(tmp[-1])&lt;br /&gt;
        tmp.pop()&lt;br /&gt;
    except:&lt;br /&gt;
        pass&lt;br /&gt;
    if len(tmp) == 0:&lt;br /&gt;
        usage(&amp;#039;Number wrong place on line: &amp;#039; + line)&lt;br /&gt;
    name = &amp;#039; &amp;#039;.join(tmp)&lt;br /&gt;
    TA_dict[name] = {&amp;#039;max&amp;#039;: maximum, &amp;#039;assigned&amp;#039;: []}&lt;br /&gt;
    TA_index.append(name)&lt;br /&gt;
infile.close()&lt;br /&gt;
&lt;br /&gt;
# Read list of students&lt;br /&gt;
infile = open(student_file, &amp;#039;r&amp;#039;)&lt;br /&gt;
st_list = list()&lt;br /&gt;
for line in infile:&lt;br /&gt;
    line = line.strip()&lt;br /&gt;
    if len(line) &amp;gt; 0 and not line.startswith(&amp;#039;#&amp;#039;):&lt;br /&gt;
        st_list.append(line)&lt;br /&gt;
        &lt;br /&gt;
infile.close()&lt;br /&gt;
&lt;br /&gt;
# Read database&lt;br /&gt;
base = dict()&lt;br /&gt;
try:&lt;br /&gt;
    infile = open(database_file, &amp;#039;r&amp;#039;)&lt;br /&gt;
    for line in infile:&lt;br /&gt;
        tmp = line.split(&amp;#039;\t&amp;#039;)&lt;br /&gt;
        if tmp[0] not in base:&lt;br /&gt;
            base[tmp[0]] = dict()&lt;br /&gt;
        base[tmp[0]][tmp[1]] = int(tmp[2])&lt;br /&gt;
    infile.close()&lt;br /&gt;
except IOError:&lt;br /&gt;
    pass&lt;br /&gt;
for TA in TA_index:&lt;br /&gt;
    if TA not in base:&lt;br /&gt;
        base[TA] = dict()&lt;br /&gt;
    for student in st_list:&lt;br /&gt;
        if student not in base[TA]:&lt;br /&gt;
            base[TA][student] = 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# randomize list&lt;br /&gt;
random.shuffle(TA_index)&lt;br /&gt;
random.shuffle(st_list)&lt;br /&gt;
&lt;br /&gt;
# find TA median&lt;br /&gt;
typetal = dict()&lt;br /&gt;
for TA in base:&lt;br /&gt;
    mylist = sorted([ base[TA][x] for x in base[TA] ])&lt;br /&gt;
    typetal[TA] = mylist[int(len(mylist)/2)]&lt;br /&gt;
&lt;br /&gt;
# make assignment&lt;br /&gt;
for student in st_list:&lt;br /&gt;
    # How many times have a TA had that student if not filled&lt;br /&gt;
    freq = { x:base[x][student] for x in TA_dict.keys() if TA_dict[x][&amp;#039;max&amp;#039;] &amp;gt; len(TA_dict[x][&amp;#039;assigned&amp;#039;]) }&lt;br /&gt;
    # What is the fewest assigned students per available TA&lt;br /&gt;
    minassigned = min([ len(TA_dict[x][&amp;#039;assigned&amp;#039;]) for x in freq.keys() ])&lt;br /&gt;
    # Who has fewest assigned&lt;br /&gt;
    freq = { x: freq[x] for x in freq.keys() if len(TA_dict[x][&amp;#039;assigned&amp;#039;]) == minassigned }&lt;br /&gt;
    # For each available TA, have they had that student more than average ?&lt;br /&gt;
    freq = { x: (base[x][student] - typetal[x]) for x in freq.keys() }&lt;br /&gt;
    # Sort according to how frequent the available TA&amp;#039;s have had the student adjusted for typetal&lt;br /&gt;
    freqsort = sorted(freq.keys(), key=freq.get)&lt;br /&gt;
    # Remove all but the ones who have had the student the fewest times&lt;br /&gt;
    freqsort = [ x for x in freqsort if freq[x] == freq[freqsort[0]] ]&lt;br /&gt;
    # Pick one at random&lt;br /&gt;
    TA = random.choice(freqsort)&lt;br /&gt;
    # Assign&lt;br /&gt;
    TA_dict[TA][&amp;#039;assigned&amp;#039;].append(student)&lt;br /&gt;
&lt;br /&gt;
# update database&lt;br /&gt;
for TA in TA_dict:&lt;br /&gt;
    for student in TA_dict[TA][&amp;#039;assigned&amp;#039;]:&lt;br /&gt;
       base[TA][student] += 1&lt;br /&gt;
&lt;br /&gt;
# Save database&lt;br /&gt;
try:&lt;br /&gt;
    outfile = open(database_file, &amp;#039;w&amp;#039;)&lt;br /&gt;
    for TA in list(base):&lt;br /&gt;
        for student in list(base[TA]):&lt;br /&gt;
            outfile.write(TA + &amp;#039;\t&amp;#039; + student + &amp;#039;\t&amp;#039; + str(base[TA][student]) + &amp;#039;\n&amp;#039;)&lt;br /&gt;
    outfile.close()&lt;br /&gt;
except IOError:&lt;br /&gt;
    print(&amp;quot;Can not save database&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Show user&lt;br /&gt;
for TA in TA_index:&lt;br /&gt;
    print(TA, &amp;#039;: &amp;#039;, sep=&amp;#039;&amp;#039;, end=&amp;#039;&amp;#039;)&lt;br /&gt;
    print(&amp;#039;; &amp;#039;.join(TA_dict[TA][&amp;#039;assigned&amp;#039;]) + &amp;quot;\n&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Assigning students to TA&amp;#039;s, Take 3 ==&lt;br /&gt;
Having done the above program, I was quite happy. I tested it with a lot of runs to see how it worked. Students were spread fairly evenly across the TA&amp;#039;s, I did notice that some TA&amp;#039;s have had one student 4 time and another 6 times. I went home, but this was nagging me. It was OK, but not completely even. Thinking about it enlightened me: The reason behind the slight unevenness is the nature of randomness and different quotas. Sometimes a student gets assigned to a &amp;quot;big&amp;quot; TA where it really should have been a &amp;quot;small&amp;quot; TA, simply due to the order the students appear in the student list (even if random).&lt;br /&gt;
&lt;br /&gt;
Time for a new approach - let the TA select which student to take instead of assigning a student to a TA.&lt;br /&gt;
&lt;br /&gt;
Notice that large parts of the program is the same, It is simply the selection method that is changed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Pseudo code&lt;br /&gt;
As long as the student list is not empty:&lt;br /&gt;
  First find a list of available TA&amp;#039;s - those who&amp;#039;s quota is not filled yet.&lt;br /&gt;
  Of those TA&amp;#039;s find the one(s) who have the fewest students assigned - to spread the load evenly.&lt;br /&gt;
  Construct all combinations of TA-student.&lt;br /&gt;
  Remove the combinations where TA has had a student more than the minimum possible.&lt;br /&gt;
  From the leftover combinations pick a random one. Any combination is a TA which has been under-assigned that student.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/python3&lt;br /&gt;
import sys&lt;br /&gt;
import random&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def usage(message=&amp;#039;&amp;#039;):&lt;br /&gt;
    &amp;#039;&amp;#039;&amp;#039;A usage message to be displayed when the user gives faulty input&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
    if message != &amp;#039;&amp;#039;:&lt;br /&gt;
        print(message)&lt;br /&gt;
    print(&amp;quot;Usage: assign_TA.py [&amp;lt;file TA list&amp;gt; &amp;lt;file student list&amp;gt; &amp;lt;database file&amp;gt;]&amp;quot;)&lt;br /&gt;
    print(&amp;quot;The list of TAs may contain a maximum of students to assign to the particular TA.&amp;quot;)&lt;br /&gt;
    print(&amp;quot;It must come after the TA&amp;#039;s name whitespace separated.&amp;quot;)&lt;br /&gt;
    print(&amp;quot;Both TA and student lists can have a # as first char - ignoring the person.&amp;quot;)&lt;br /&gt;
    print(&amp;quot;The standard filenames are TA_list.txt, student_list.txt and database.txt&amp;quot;)&lt;br /&gt;
    print(&amp;quot;The database is for keeping track of assignments, so they are shared equally.&amp;quot;)&lt;br /&gt;
    print(&amp;quot;The database is reset by deleting it. Do it once every season.&amp;quot;)&lt;br /&gt;
    sys.exit(1)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#display help if requested or run without arguments&lt;br /&gt;
if len(sys.argv) == 1:&lt;br /&gt;
    TA_file = &amp;#039;TA_list.txt&amp;#039;&lt;br /&gt;
    student_file = &amp;#039;student_list.txt&amp;#039;&lt;br /&gt;
    database_file = &amp;#039;database.txt&amp;#039;&lt;br /&gt;
elif sys.argv[1] in (&amp;#039;-h&amp;#039;, &amp;#039;--help&amp;#039;, &amp;#039;-?&amp;#039;):&lt;br /&gt;
    usage()&lt;br /&gt;
elif len(sys.argv) == 4:&lt;br /&gt;
    TA_file = sys.argv[1]&lt;br /&gt;
    student_file = sys.argv[2]&lt;br /&gt;
    database_file = sys.argv[3]&lt;br /&gt;
else:&lt;br /&gt;
    usage()&lt;br /&gt;
&lt;br /&gt;
# Read TA list&lt;br /&gt;
TA_dict = dict()&lt;br /&gt;
TA_index = list()&lt;br /&gt;
infile = open(TA_file, &amp;#039;r&amp;#039;)&lt;br /&gt;
for line in infile:&lt;br /&gt;
    tmp = line.split()&lt;br /&gt;
    if len(tmp) == 0 or tmp[0].startswith(&amp;#039;#&amp;#039;):&lt;br /&gt;
        continue&lt;br /&gt;
    #if there is a second column this is the max value of students for that TA&lt;br /&gt;
    maximum = 20&lt;br /&gt;
    try:&lt;br /&gt;
        maximum = int(tmp[-1])&lt;br /&gt;
        tmp.pop()&lt;br /&gt;
    except:&lt;br /&gt;
        pass&lt;br /&gt;
    if len(tmp) == 0:&lt;br /&gt;
        usage(&amp;#039;Number wrong place on line: &amp;#039; + line)&lt;br /&gt;
    name = &amp;#039; &amp;#039;.join(tmp)&lt;br /&gt;
    TA_dict[name] = {&amp;#039;max&amp;#039;: maximum, &amp;#039;assigned&amp;#039;: []}&lt;br /&gt;
    TA_index.append(name)&lt;br /&gt;
infile.close()&lt;br /&gt;
&lt;br /&gt;
# Read list of students&lt;br /&gt;
infile = open(student_file, &amp;#039;r&amp;#039;)&lt;br /&gt;
st_list = list()&lt;br /&gt;
for line in infile:&lt;br /&gt;
    line = line.strip()&lt;br /&gt;
    if len(line) &amp;gt; 0 and not line.startswith(&amp;#039;#&amp;#039;):&lt;br /&gt;
        st_list.append(line)&lt;br /&gt;
        &lt;br /&gt;
infile.close()&lt;br /&gt;
&lt;br /&gt;
# Read database&lt;br /&gt;
base = dict()&lt;br /&gt;
try:&lt;br /&gt;
    infile = open(database_file, &amp;#039;r&amp;#039;)&lt;br /&gt;
    for line in infile:&lt;br /&gt;
        tmp = line.split(&amp;#039;\t&amp;#039;)&lt;br /&gt;
        if tmp[0] not in base:&lt;br /&gt;
            base[tmp[0]] = dict()&lt;br /&gt;
        base[tmp[0]][tmp[1]] = int(tmp[2])&lt;br /&gt;
    infile.close()&lt;br /&gt;
except IOError:&lt;br /&gt;
    pass&lt;br /&gt;
for TA in TA_index:&lt;br /&gt;
    if TA not in base:&lt;br /&gt;
        base[TA] = dict()&lt;br /&gt;
    for student in st_list:&lt;br /&gt;
        if student not in base[TA]:&lt;br /&gt;
            base[TA][student] = 0&lt;br /&gt;
&lt;br /&gt;
# make assignment; goal is to spread out TA&amp;#039;s evenly on students &lt;br /&gt;
while len(st_list) &amp;gt; 0:&lt;br /&gt;
    # Find TA&amp;#039;s who can still take on students&lt;br /&gt;
    TA_avail = [ TA for TA in TA_index if TA_dict[TA][&amp;#039;max&amp;#039;] &amp;gt; len(TA_dict[TA][&amp;#039;assigned&amp;#039;]) ]&lt;br /&gt;
    # Making sure the burden is evenly spread, by removing those with more than minimum assigned&lt;br /&gt;
    minimum = min([ len(TA_dict[TA][&amp;#039;assigned&amp;#039;]) for TA in TA_avail ])&lt;br /&gt;
    TA_avail = [ TA for TA in TA_avail if len(TA_dict[TA][&amp;#039;assigned&amp;#039;]) == minimum ]&lt;br /&gt;
    # Make all TA-student combinations&lt;br /&gt;
    combi = { (TA, stud): base[TA][stud] for TA in TA_avail for stud in st_list }&lt;br /&gt;
    # Find the the combinations with fewest assigned&lt;br /&gt;
    minimum = min(list(combi.values()))    &lt;br /&gt;
    # Remove combinations greater than the fewest assigned, notice transition to list&lt;br /&gt;
    combi = [ k for k in combi if combi[k] == minimum ]&lt;br /&gt;
    # Pick random combinations until set is empty&lt;br /&gt;
    while len(combi) &amp;gt; 0:&lt;br /&gt;
        # Pick and assign&lt;br /&gt;
        (TA, student) = random.choice(combi)&lt;br /&gt;
        TA_dict[TA][&amp;#039;assigned&amp;#039;].append(student)&lt;br /&gt;
        st_list.remove(student)&lt;br /&gt;
        # Remove combinations with TA and student&lt;br /&gt;
        combi = [ k for k in combi if k[0] != TA and k[1] != student ]&lt;br /&gt;
# update database&lt;br /&gt;
for TA in TA_dict:&lt;br /&gt;
    for student in TA_dict[TA][&amp;#039;assigned&amp;#039;]:&lt;br /&gt;
       base[TA][student] += 1&lt;br /&gt;
&lt;br /&gt;
# Save database&lt;br /&gt;
try:&lt;br /&gt;
    outfile = open(database_file, &amp;#039;w&amp;#039;)&lt;br /&gt;
    for TA in list(base):&lt;br /&gt;
        for student in list(base[TA]):&lt;br /&gt;
            outfile.write(TA + &amp;#039;\t&amp;#039; + student + &amp;#039;\t&amp;#039; + str(base[TA][student]) + &amp;#039;\n&amp;#039;)&lt;br /&gt;
    outfile.close()&lt;br /&gt;
except IOError:&lt;br /&gt;
    print(&amp;quot;Can not save database&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# Show user&lt;br /&gt;
for TA in TA_index:&lt;br /&gt;
    print(TA, &amp;#039;: &amp;#039;, sep=&amp;#039;&amp;#039;, end=&amp;#039;&amp;#039;)&lt;br /&gt;
    print(&amp;#039;; &amp;#039;.join(TA_dict[TA][&amp;#039;assigned&amp;#039;]) + &amp;quot;\n&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This program spreads the load both random and evenly, both with regards to number of students assigned, and which TA they are assigned to.&amp;lt;br&amp;gt;&lt;br /&gt;
Beautiful.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
</feed>