Skip to content

Commit 2941d88

Browse files
committed
Added exercises
1 parent dc3cf44 commit 2941d88

5 files changed

+1740
-473
lines changed

Lecture-0-Setup-of-Python-Environment.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"## Start jupyter notebook\n",
7373
"\n",
7474
"```\n",
75-
"$ source activate gwas-lecture\n",
75+
"$ conda activate gwas-lecture\n",
7676
"$ jupyter notebook\n",
7777
"```\n",
7878
"Open link that is displayed in terminal in browser \n",
@@ -110,7 +110,7 @@
110110
"name": "python",
111111
"nbconvert_exporter": "python",
112112
"pygments_lexer": "ipython3",
113-
"version": "3.6.10"
113+
"version": "3.6.12"
114114
}
115115
},
116116
"nbformat": 4,

Lecture-1-Introduction-to-Jupyter-Notebooks.ipynb

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
]
7878
},
7979
{
80-
"attachments": {},
8180
"cell_type": "markdown",
8281
"metadata": {},
8382
"source": [
@@ -706,6 +705,76 @@
706705
"ls"
707706
]
708707
},
708+
{
709+
"cell_type": "markdown",
710+
"metadata": {},
711+
"source": [
712+
"## Excercices \n",
713+
"\n",
714+
"Here are some excercises to test your knowledge"
715+
]
716+
},
717+
{
718+
"cell_type": "markdown",
719+
"metadata": {},
720+
"source": [
721+
"<div class=\"alert alert-success\">\n",
722+
"Implement the function <code>hello</code> and make sure the test cells runs without any errors. You will need to delete the line with `raise NotImplementedError`, write your own solution, and then re-run the cell before running the test cell. Each time you change code in a cell, you will need to re-run that cell before running any other cells that depend on it!\n",
723+
"</div>"
724+
]
725+
},
726+
{
727+
"cell_type": "code",
728+
"execution_count": 1,
729+
"metadata": {},
730+
"outputs": [],
731+
"source": [
732+
"def hello(name):\n",
733+
" \"\"\"Returns a message containing \"Hello, <name>!\", \n",
734+
" where <name> is passed in as an argument.\n",
735+
" \n",
736+
" Parameters\n",
737+
" ----------\n",
738+
" name : string\n",
739+
" The name of the person to say hello to\n",
740+
" \n",
741+
" Returns\n",
742+
" -------\n",
743+
" the message containing \"Hello, <name>!\"\n",
744+
" \n",
745+
" \"\"\"\n",
746+
" ### BEGIN SOLUTION\n",
747+
" raise NotImplementedError()\n",
748+
" ### END SOLUTION"
749+
]
750+
},
751+
{
752+
"cell_type": "code",
753+
"execution_count": null,
754+
"metadata": {},
755+
"outputs": [],
756+
"source": [
757+
"# try running your hello function with your own name and see what \n",
758+
"# it returns\n",
759+
"hello(\"YOUR NAME HERE\")"
760+
]
761+
},
762+
{
763+
"cell_type": "code",
764+
"execution_count": null,
765+
"metadata": {},
766+
"outputs": [],
767+
"source": [
768+
"\"\"\"(1 point) Test code for the 'hello' function. This cell should NOT give any errors when it is run.\"\"\"\n",
769+
"from nose.tools import assert_equal\n",
770+
"assert_equal(hello(\"Jessica\"), \"Hello, Jessica!\")\n",
771+
"assert_equal(hello(\"jessica\"), \"Hello, jessica!\")\n",
772+
"assert_equal(hello(\"Tom\"), \"Hello, Tom!\")\n",
773+
"assert_equal(hello(\"123\"), \"Hello, 123!\")\n",
774+
"\n",
775+
"print(\"Success!\")"
776+
]
777+
},
709778
{
710779
"cell_type": "code",
711780
"execution_count": null,

0 commit comments

Comments
 (0)