diff --git a/your-code/main.ipynb b/your-code/main.ipynb index 01257d4..9a1a534 100755 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -25,14 +25,15 @@ "metadata": {}, "outputs": [], "source": [ - "def modify_list(lst, lmbda):\n", + "def modify_list(lst, lambda_expression()):\n", " \"\"\"\n", " Input: list and lambda expression\n", " Output: the transformed list\n", - " \"\"\"\n", - " \n", - " # your code here\n", - " " + " \"\"\"\n", + " for element in list:\n", + " lambda_expression()\n", + " \n", + " # your code here" ] }, { @@ -50,7 +51,9 @@ "metadata": {}, "outputs": [], "source": [ - "# your code here" + "# your code here\n", + "\n", + "f = lambda x: x + 273.15\n" ] }, { @@ -62,12 +65,23 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[285.15, 296.15, 311.15, 218.14999999999998, 297.15]\n" + ] + } + ], "source": [ "temps = [12, 23, 38, -55, 24]\n", "\n", + "temps_kelvin = list(map(lambda temps: temps + 273.15, temps))\n", + "print(temps_kelvin)\n", + "\n", "# your code here" ] }, @@ -82,11 +96,12 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "# your code here\n", + "mod = lambda x, y: 1 if x %y == 0 else 0" ] }, { @@ -100,17 +115,17 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ - "def divisor(b):\n", + "def divisor(x):\n", " \"\"\"\n", " Input: a number\n", " Output: a function that returns 1 if the number is \n", " divisible by another number (to be passed later) and zero otherwise.\n", " \"\"\"\n", - " \n", + " return mod(x,y)\n", " # your code here" ] }, @@ -123,11 +138,12 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "# your code here\n", + "divisibles = divisor(5)" ] }, { @@ -139,9 +155,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'divisible5' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdivisible5\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m10\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;31mNameError\u001b[0m: name 'divisible5' is not defined" + ] + } + ], "source": [ "divisible5(10)" ] @@ -269,7 +297,20 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.8.3" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false } }, "nbformat": 4,