From aa9120155539f799bcfe53dadfe93e33dc4477a5 Mon Sep 17 00:00:00 2001 From: karthik-aru Date: Thu, 14 Jan 2021 17:53:39 +0100 Subject: [PATCH] Solved --- your-code/main.ipynb | 106 +++++++++++++++++++++++++++++++++---------- 1 file changed, 82 insertions(+), 24 deletions(-) diff --git a/your-code/main.ipynb b/your-code/main.ipynb index 01257d4..0d966a8 100755 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -21,7 +21,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -32,7 +32,8 @@ " \"\"\"\n", " \n", " # your code here\n", - " " + " \n", + " return list(map(lmbda, lst))" ] }, { @@ -46,11 +47,13 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "# your code here\n", + "\n", + "CtoK = lambda C: C + 273.15" ] }, { @@ -62,13 +65,23 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "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", - "# your code here" + "# your code here\n", + "\n", + "print(modify_list(temps, CtoK))" ] }, { @@ -82,11 +95,13 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "# your code here\n", + "\n", + "mod = lambda x,y : 1 if x%y == 0 else 0" ] }, { @@ -100,7 +115,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -111,7 +126,9 @@ " divisible by another number (to be passed later) and zero otherwise.\n", " \"\"\"\n", " \n", - " # your code here" + " # your code here\n", + " \n", + " return lambda x : 1 if x%b == 0 else 0" ] }, { @@ -123,11 +140,13 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "# your code here\n", + "\n", + "divisible5 = divisor(5)" ] }, { @@ -139,18 +158,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "divisible5(10)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "divisible5(8)" ] @@ -168,7 +209,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 20, "metadata": {}, "outputs": [ { @@ -177,7 +218,7 @@ "[(1,), (2,), (3,), (4,), (5,)]" ] }, - "execution_count": 10, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -199,14 +240,30 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 22, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[('Green', 'eggs'),\n", + " ('cheese', 'cheese'),\n", + " ('English', 'cucumber'),\n", + " ('tomato', 'tomato')]" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "list1 = ['Green', 'cheese', 'English', 'tomato']\n", "list2 = ['eggs', 'cheese', 'cucumber', 'tomato']\n", "\n", - "# your code here" + "# your code here\n", + "\n", + "[(L1, L2) for L1,L2 in zip(list1,list2)]" ] }, { @@ -229,7 +286,8 @@ "list1 = ['Engineering', 'Computer Science', 'Political Science', 'Mathematics']\n", "list2 = ['Lab', 'Homework', 'Essay', 'Module']\n", "\n", - "# your code here" + "# your code here\n", + "\n" ] }, { @@ -269,7 +327,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.7.6" } }, "nbformat": 4,