Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 117 additions & 8 deletions pairem.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
Expand All @@ -50,10 +49,9 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
Expand All @@ -68,17 +66,93 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 19,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Felix Adam', 'Sixter Leonardo Alcivar', 'Julia Bois Barnett', 'Eric Alan Beckwith', 'Maia Brenner Stainfeld', 'Hannah Busshoff', 'Hector Eulogio Cano', 'Reid Falconer', 'Lucas Freire', 'Hannah Gerits', 'Georgi Konstantinov Gulyashki', 'Ari Lam', 'Sam Peter MacIntyre', 'Oscar Martínez', 'Monika Anna Matyja', 'Evelyn Maria Molina Bolaños', 'Jordi Morera Serra', 'Konstantinos Niakaros', 'Snorri Petersen', 'Maryam Rahbaralam', 'Guillem Sitges', 'Callan James Windsor', 'Sebastian Wolf', 'Kaka Ye', 'Maximilian Zebhauser']\n"
]
}
],
"source": [
"import random \n",
"def data random\n",
"student_list = [student[\"First Name\"] + \" \" + student[\"Last Name\"] \n",
" for student in students]\n",
"print(student_list)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"ename": "SyntaxError",
"evalue": "invalid syntax (<ipython-input-25-13c91b7bdea8>, line 16)",
"output_type": "error",
"traceback": [
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-25-13c91b7bdea8>\"\u001b[0;36m, line \u001b[0;32m16\u001b[0m\n\u001b[0;31m pair = [student, other student]\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n"
]
}
],
"source": [
"\n",
"\n",
"\n",
"\n",
"import random\n",
"random.shuffle(student_list)\n",
"\n",
"if len(student_list)%2 != 0 :\n",
" random_student_list.pop()\n",
"\n",
"half = round(len(student_list)/2)\n",
"\n",
"student_pairs = []\n",
"\n",
"i = 1\n",
"\n",
"for student in student_list[:half]:\n",
" other_student = student_list[-i]\n",
" i += 1\n",
" pair = [student, other student] \n",
" student_pairs.append(pair)\n",
" \n",
" student_pairs[0].append(pair)\n",
"\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"outputs": [
{
"ename": "AssertionError",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-9-0e882289e051>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[0;32massert\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpairs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mlist\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[0;32massert\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpairs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m<\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 17\u001b[0;31m \u001b[0;32massert\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpairs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m>\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 18\u001b[0m \u001b[0;32massert\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpairs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0;34m\"\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 19\u001b[0m \u001b[0;32massert\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpairs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0;34m\"\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mAssertionError\u001b[0m: "
]
}
],
"source": [
"# Write your own test for the assignment!\n",
"\n",
Expand All @@ -93,15 +167,50 @@
"pairs = make_pairs(test_students)\n",
"\n",
"# Write assertions here!\n",
"assert(type(pairs) == list)"
"assert(type(pairs) == list)\n",
"assert(type(pairs[:]) == list)\n",
"assert(len(pairs[:])<4)\n",
"assert(len(pairs[:])>1)\n",
"assert(pairs[:][1] != \"\")\n",
"assert(pairs[:][2] != \"\")\n",
"assert(pairs[:][3] != \"\")\n",
"assert(pairs[:][4] != \"\")\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
},
"name": "Untitled.ipynb"
},
"nbformat": 4,
Expand Down