|
77 | 77 | ]
|
78 | 78 | },
|
79 | 79 | {
|
80 |
| - "attachments": {}, |
81 | 80 | "cell_type": "markdown",
|
82 | 81 | "metadata": {},
|
83 | 82 | "source": [
|
|
706 | 705 | "ls"
|
707 | 706 | ]
|
708 | 707 | },
|
| 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 | + }, |
709 | 778 | {
|
710 | 779 | "cell_type": "code",
|
711 | 780 | "execution_count": null,
|
|
0 commit comments