From 2cc97d730871188351d2614a37e653fcbc9a23a0 Mon Sep 17 00:00:00 2001 From: Adriraj-09 <55662182+Adriraj-09@users.noreply.github.com> Date: Thu, 5 Mar 2020 21:18:42 +0530 Subject: [PATCH 1/2] Assignment problem solved by Adriraj --- Questions/Excercise numpy .ipynb | 132 +++++++++++++++---------------- 1 file changed, 65 insertions(+), 67 deletions(-) diff --git a/Questions/Excercise numpy .ipynb b/Questions/Excercise numpy .ipynb index 671389b..6322d0c 100644 --- a/Questions/Excercise numpy .ipynb +++ b/Questions/Excercise numpy .ipynb @@ -29,18 +29,18 @@ "metadata": { "id": "LIP5u4zi0Nmg", "colab_type": "code", + "outputId": "33b2d6e8-8f01-4ae8-baaf-e7b7144dff12", "colab": { "base_uri": "https://localhost:8080/", - "height": 210 - }, - "outputId": "134a627c-b3fe-44de-80c4-e1aad6982509" + "height": 204 + } }, "source": [ "import numpy as np #import numpy\n", - "a = np.linspace(-1.3,2.5,64)\n", - "print(a)" + "b = np.linspace(-1.3,2.5,64)\n", + "print(b)" ], - "execution_count": 3, + "execution_count": 1, "outputs": [ { "output_type": "stream", @@ -76,28 +76,28 @@ "metadata": { "id": "4TxT66309n1o", "colab_type": "code", + "outputId": "c7f9cd9b-c670-432d-ec41-3f47b522e0cb", "colab": { "base_uri": "https://localhost:8080/", - "height": 70 - }, - "outputId": "bbc54490-654d-48b5-e67b-4b2259a4bb4a" + "height": 68 + } }, "source": [ "import numpy as np\n", - "a=np.array([1,2,3])\n", - "print (a)\n", - "n=input(\"Enter the array length : \")\n", - "b=np.resize(a,(3*int(n)))\n", + "s=np.array([1,2,3])\n", + "print (s)\n", + "ns=input(\"Enter the length of the array: \")\n", + "b=np.resize(s,(3*int(ns)))\n", "print (b)" ], - "execution_count": 2, + "execution_count": 17, "outputs": [ { "output_type": "stream", "text": [ "[1 2 3]\n", - "Enter the array length : 6\n", - "[1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3]\n" + "Enter the length of the array: 5\n", + "[1 2 3 1 2 3 1 2 3 1 2 3 1 2 3]\n" ], "name": "stdout" } @@ -118,23 +118,23 @@ "metadata": { "id": "ebhEUZq29r32", "colab_type": "code", + "outputId": "16ac0d6e-0538-4a55-f6af-ef4c7d14074b", "colab": { "base_uri": "https://localhost:8080/", "height": 34 - }, - "outputId": "9e141103-cd42-4d5e-eb81-2fad744e8d33" + } }, "source": [ "import numpy as np\n", - "array=np.arange(1,10,2)\n", - "print(array) " + "a=np.arange(1,20,2)\n", + "print(a) " ], "execution_count": 4, "outputs": [ { "output_type": "stream", "text": [ - "[1 3 5 7 9]\n" + "[ 1 3 5 7 9 11 13 15 17 19]\n" ], "name": "stdout" } @@ -155,24 +155,24 @@ "metadata": { "id": "gOlfuJCo-JwF", "colab_type": "code", + "outputId": "c645e5d0-6880-4b90-a242-a04415ab2966", "colab": { "base_uri": "https://localhost:8080/", "height": 34 - }, - "outputId": "8a61deea-16b2-4570-a9a3-a15592e0568e" + } }, "source": [ "import numpy as np\n", - "array1 = np.array([1,2,3,2,3,4,3,4,5,6])\n", - "array2 = np.array([7,2,10,2,7,4,9,4,9,8])\n", - "print(np.intersect1d(array1,array2))" + "a1 = np.array([1,2,3,4,5])\n", + "a2 = np.array([5,6,7,4,5,3])\n", + "print(np.intersect1d(a1,a2))" ], - "execution_count": 7, + "execution_count": 5, "outputs": [ { "output_type": "stream", "text": [ - "[2 4]\n" + "[3 4 5]\n" ], "name": "stdout" } @@ -193,11 +193,11 @@ "metadata": { "id": "2E8b55_2Cjx5", "colab_type": "code", + "outputId": "9561727d-d1d6-4957-ff3d-3c8e1e054a59", "colab": { "base_uri": "https://localhost:8080/", "height": 52 - }, - "outputId": "9561727d-d1d6-4957-ff3d-3c8e1e054a59" + } }, "source": [ "import numpy as np\n", @@ -205,7 +205,7 @@ "b = np.reshape(a,(2,5))\n", "print(b)" ], - "execution_count": 8, + "execution_count": 0, "outputs": [ { "output_type": "stream", @@ -224,7 +224,7 @@ "colab_type": "text" }, "source": [ - "6) Create a numpy array to list and vice versa" + "6) Change a numpy array to list and vice versa" ] }, { @@ -232,23 +232,23 @@ "metadata": { "id": "TLWmsiiR0-T6", "colab_type": "code", + "outputId": "71be9de2-b1e8-4c78-a0e3-fbfd9b605df1", "colab": { "base_uri": "https://localhost:8080/", "height": 34 - }, - "outputId": "c9b67724-e858-4367-e411-4bceaf720157" + } }, "source": [ "import numpy as np\n", - "array = np.array([0,1,2,3,4,5,6,7,8,9])\n", + "array = np.array([1,2,3,3,4,5,6,6,5,9])\n", "print(array.tolist()) #array to list" ], - "execution_count": 20, + "execution_count": 6, "outputs": [ { "output_type": "stream", "text": [ - "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n" + "[1, 2, 3, 3, 4, 5, 6, 6, 5, 9]\n" ], "name": "stdout" } @@ -259,24 +259,24 @@ "metadata": { "id": "DGcqFBR51jfh", "colab_type": "code", + "outputId": "0e0ab628-6f45-4743-ced3-5e9e0b578e0f", "colab": { "base_uri": "https://localhost:8080/", "height": 34 - }, - "outputId": "0710a28e-91c5-42ad-ebef-f29f2ee4fe30" + } }, "source": [ "import numpy as np\n", - "list = [0,1,2,3,4,5,6,7,8,9]\n", - "array = np.array(list)\n", - "print(array) #list to array\n" + "list = [1,2,3,3,4,5,6,6,5,9]\n", + "a = np.array(list)\n", + "print(a) #list to array\n" ], - "execution_count": 23, + "execution_count": 9, "outputs": [ { "output_type": "stream", "text": [ - "[0 1 2 3 4 5 6 7 8 9]\n" + "[1 2 3 3 4 5 6 6 5 9]\n" ], "name": "stdout" } @@ -297,27 +297,27 @@ "metadata": { "id": "4bjP3JAc9vRD", "colab_type": "code", + "outputId": "18cf9359-e895-436f-f5a8-ef61da17c75c", "colab": { "base_uri": "https://localhost:8080/", - "height": 439 - }, - "outputId": "c6133be3-6ab5-4093-adb1-140e752eb782" + "height": 425 + } }, "source": [ "import numpy as np\n", - "x = np.zeros((10,10))\n", - "print(\"1st array(10x10):\")\n", - "print(x)\n", - "print(\"after framing:\")\n", - "x = np.pad(x, pad_width=1, mode='constant', constant_values=1)\n", - "print(x)" + "a = np.zeros((10,10))\n", + "print(\"Array of 10X10 before framing:\")\n", + "print(a)\n", + "print(\"Array of 10X10 after framing:\")\n", + "a = np.pad(a, pad_width=1, mode='constant', constant_values=1)\n", + "print(a)" ], - "execution_count": 11, + "execution_count": 12, "outputs": [ { "output_type": "stream", "text": [ - "1st array(10x10):\n", + "Array of 10X10 before framing:\n", "[[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n", " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n", " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n", @@ -328,7 +328,7 @@ " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n", " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n", " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]]\n", - "after framing:\n", + "Array of 10X10 after framing:\n", "[[1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]\n", " [1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1.]\n", " [1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1.]\n", @@ -361,27 +361,25 @@ "metadata": { "id": "No7fx0Xy9zEh", "colab_type": "code", + "outputId": "8c4fcd58-104c-48c3-e89e-0387e7caf3b5", "colab": { "base_uri": "https://localhost:8080/", - "height": 175 - }, - "outputId": "4221ede7-f391-4b0f-f1af-939948521411" + "height": 153 + } }, "source": [ "import numpy as np\n", - "x = np.ones((3,3))\n", - "print(\"Checkerboard pattern:\")\n", - "x = np.zeros((8,8),dtype=int)\n", - "x[1::2,::2] = 1\n", - "x[::2,1::2] = 1\n", - "print(x)" + "a = np.ones((3,3))\n", + "a = np.zeros((8,8),dtype=int)\n", + "a[1::2,::2] = 1\n", + "a[::2,1::2] = 1\n", + "print(a)\n" ], - "execution_count": 12, + "execution_count": 28, "outputs": [ { "output_type": "stream", "text": [ - "Checkerboard pattern:\n", "[[0 1 0 1 0 1 0 1]\n", " [1 0 1 0 1 0 1 0]\n", " [0 1 0 1 0 1 0 1]\n", From 313ecc2301677890915214ef7d38dac345e02b04 Mon Sep 17 00:00:00 2001 From: Adriraj-09 <55662182+Adriraj-09@users.noreply.github.com> Date: Thu, 5 Mar 2020 23:16:01 +0530 Subject: [PATCH 2/2] List1 assignment completed by me. --- Questions/List 1.ipynb | 126 ++++++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 65 deletions(-) diff --git a/Questions/List 1.ipynb b/Questions/List 1.ipynb index 84accf7..41a908e 100644 --- a/Questions/List 1.ipynb +++ b/Questions/List 1.ipynb @@ -37,15 +37,15 @@ "metadata": { "id": "bjl-2QkznWid", "colab_type": "code", + "outputId": "31d2161f-989f-4833-e627-55e2829a0739", "colab": { "base_uri": "https://localhost:8080/", "height": 34 - }, - "outputId": "4aeceb43-18b6-4d26-ca05-568c2800ce2b" + } }, "source": [ - "list = [1,2,3,4,5,6,7,8,9]\n", - "dummy_list = list\n", + "a = [1,3,5,6,7,9,10,11,13,15]\n", + "dummy_list = a\n", "print(dummy_list)" ], "execution_count": 1, @@ -53,7 +53,7 @@ { "output_type": "stream", "text": [ - "[1, 2, 3, 4, 5, 6, 7, 8, 9]\n" + "[1, 3, 5, 6, 7, 9, 10, 11, 13, 15]\n" ], "name": "stdout" } @@ -74,11 +74,11 @@ "metadata": { "id": "RVL5178inz9M", "colab_type": "code", + "outputId": "9ed67958-c462-476a-c169-79177708769d", "colab": { "base_uri": "https://localhost:8080/", "height": 34 - }, - "outputId": "6cc5426d-17da-42e6-de25-2ca02988484a" + } }, "source": [ "print(dummy_list)" @@ -88,7 +88,7 @@ { "output_type": "stream", "text": [ - "[1, 2, 3, 4, 5, 6, 7, 8, 9]\n" + "[1, 3, 5, 6, 7, 9, 10, 11, 13, 15]\n" ], "name": "stdout" } @@ -109,26 +109,26 @@ "metadata": { "id": "0Q5yeD9x9xIA", "colab_type": "code", + "outputId": "66a580b5-38af-4b47-d45c-185436be3b2f", "colab": { "base_uri": "https://localhost:8080/", "height": 34 - }, - "outputId": "5c8c2ebf-dca1-497f-a916-294206cdab80" + } }, "source": [ "def Reverse(dummy_list): \n", - "\tnew_list = dummy_list[::-1] \n", - "\treturn new_list \n", + "\tlist = dummy_list[::-1] \n", + "\treturn list \n", "\t\n", - "dummy_list = [1,2,3,4,5,6,7,8,9] \n", + "dummy_list = [1,3,5,6,7,9,10,11,13,15] \n", "print(Reverse(dummy_list)) " ], - "execution_count": 8, + "execution_count": 3, "outputs": [ { "output_type": "stream", "text": [ - "[9, 8, 7, 6, 5, 4, 3, 2, 1]\n" + "[15, 13, 11, 10, 9, 7, 6, 5, 3, 1]\n" ], "name": "stdout" } @@ -161,7 +161,7 @@ "cell_type": "code", "metadata": { "colab_type": "code", - "outputId": "b1f3b7a6-2eea-4b82-f0ad-53ec5a0eb962", + "outputId": "e556787f-063a-4db3-8ff9-952b192605b3", "id": "5u_ZzmmJ-d1j", "colab": { "base_uri": "https://localhost:8080/", @@ -169,17 +169,17 @@ } }, "source": [ - "dummy_list = [1,2,3,4,5,6,7,8,9]\n", + "dummy_list = [1,3,5,6,7,9,10,11,13,15]\n", "dummy_list_2 = [2, 200, 16, 4, 1, 0, 9.45, 45.67, 90, 12.01, 12.02]\n", "dummy_list = dummy_list + dummy_list_2\n", "print(dummy_list)" ], - "execution_count": 10, + "execution_count": 4, "outputs": [ { "output_type": "stream", "text": [ - "[1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 200, 16, 4, 1, 0, 9.45, 45.67, 90, 12.01, 12.02]\n" + "[1, 3, 5, 6, 7, 9, 10, 11, 13, 15, 2, 200, 16, 4, 1, 0, 9.45, 45.67, 90, 12.01, 12.02]\n" ], "name": "stdout" } @@ -200,14 +200,14 @@ "metadata": { "id": "Nsm8sYPyJoVU", "colab_type": "code", - "outputId": "5d3d7ab9-4132-446c-dae9-d2019517f8c4", + "outputId": "83808e72-b569-4a90-9c97-c2c575a65acc", "colab": { "base_uri": "https://localhost:8080/", - "height": 263 + "height": 187 } }, "source": [ - "dummy_list = [1,2,3,2,200,16,4,1,0,9.45,45.67,90,12.01,12.02]\n", + "dummy_list = [1,3,5,6,7,9,10,11,13,15]\n", "\n", "dummy_dict = {}\n", "\n", @@ -215,25 +215,21 @@ " dummy_dict[dummy_list[i]] = dummy_list.count(dummy_list[i])\n", " print(dummy_dict)" ], - "execution_count": 11, + "execution_count": 5, "outputs": [ { "output_type": "stream", "text": [ - "{1: 2}\n", - "{1: 2, 2: 2}\n", - "{1: 2, 2: 2, 3: 1}\n", - "{1: 2, 2: 2, 3: 1}\n", - "{1: 2, 2: 2, 3: 1, 200: 1}\n", - "{1: 2, 2: 2, 3: 1, 200: 1, 16: 1}\n", - "{1: 2, 2: 2, 3: 1, 200: 1, 16: 1, 4: 1}\n", - "{1: 2, 2: 2, 3: 1, 200: 1, 16: 1, 4: 1}\n", - "{1: 2, 2: 2, 3: 1, 200: 1, 16: 1, 4: 1, 0: 1}\n", - "{1: 2, 2: 2, 3: 1, 200: 1, 16: 1, 4: 1, 0: 1, 9.45: 1}\n", - "{1: 2, 2: 2, 3: 1, 200: 1, 16: 1, 4: 1, 0: 1, 9.45: 1, 45.67: 1}\n", - "{1: 2, 2: 2, 3: 1, 200: 1, 16: 1, 4: 1, 0: 1, 9.45: 1, 45.67: 1, 90: 1}\n", - "{1: 2, 2: 2, 3: 1, 200: 1, 16: 1, 4: 1, 0: 1, 9.45: 1, 45.67: 1, 90: 1, 12.01: 1}\n", - "{1: 2, 2: 2, 3: 1, 200: 1, 16: 1, 4: 1, 0: 1, 9.45: 1, 45.67: 1, 90: 1, 12.01: 1, 12.02: 1}\n" + "{1: 1}\n", + "{1: 1, 3: 1}\n", + "{1: 1, 3: 1, 5: 1}\n", + "{1: 1, 3: 1, 5: 1, 6: 1}\n", + "{1: 1, 3: 1, 5: 1, 6: 1, 7: 1}\n", + "{1: 1, 3: 1, 5: 1, 6: 1, 7: 1, 9: 1}\n", + "{1: 1, 3: 1, 5: 1, 6: 1, 7: 1, 9: 1, 10: 1}\n", + "{1: 1, 3: 1, 5: 1, 6: 1, 7: 1, 9: 1, 10: 1, 11: 1}\n", + "{1: 1, 3: 1, 5: 1, 6: 1, 7: 1, 9: 1, 10: 1, 11: 1, 13: 1}\n", + "{1: 1, 3: 1, 5: 1, 6: 1, 7: 1, 9: 1, 10: 1, 11: 1, 13: 1, 15: 1}\n" ], "name": "stdout" } @@ -267,21 +263,21 @@ "metadata": { "id": "qe5E5IgxpTWU", "colab_type": "code", + "outputId": "1f15afbe-4856-4888-c602-7c62c3f83d4a", "colab": { "base_uri": "https://localhost:8080/", "height": 34 - }, - "outputId": "9e2211bc-ae23-4685-e5eb-9499038850bb" + } }, "source": [ "print(dummy_dict)" ], - "execution_count": 12, + "execution_count": 6, "outputs": [ { "output_type": "stream", "text": [ - "{1: 2, 2: 2, 3: 1, 200: 1, 16: 1, 4: 1, 0: 1, 9.45: 1, 45.67: 1, 90: 1, 12.01: 1, 12.02: 1}\n" + "{1: 1, 3: 1, 5: 1, 6: 1, 7: 1, 9: 1, 10: 1, 11: 1, 13: 1, 15: 1}\n" ], "name": "stdout" } @@ -301,7 +297,7 @@ "cell_type": "code", "metadata": { "colab_type": "code", - "outputId": "a00db804-52c0-425d-cab1-8d791122c091", + "outputId": "a95b5328-2456-4d09-ddf1-42c5f27b137f", "id": "tFVJt1_x_nxr", "colab": { "base_uri": "https://localhost:8080/", @@ -309,16 +305,16 @@ } }, "source": [ - "dummy_list = [1,2,3,2,200,16,4,1,0,9.45,45.67,90,12.01,12.02]\n", + "dummy_list = [1,3,5,6,7,9,10,11,13,15]\n", "dummy_list.sort()\n", "print(dummy_list)\n" ], - "execution_count": 14, + "execution_count": 7, "outputs": [ { "output_type": "stream", "text": [ - "[0, 1, 1, 2, 2, 3, 4, 9.45, 12.01, 12.02, 16, 45.67, 90, 200]\n" + "[1, 3, 5, 6, 7, 9, 10, 11, 13, 15]\n" ], "name": "stdout" } @@ -341,7 +337,7 @@ "cell_type": "code", "metadata": { "colab_type": "code", - "outputId": "a1cd7a2d-793b-4002-dbbd-faa01756c06e", + "outputId": "7417a6ed-1591-45dc-ae7b-bd8210a7886a", "id": "YY2mWZkh_vHl", "colab": { "base_uri": "https://localhost:8080/", @@ -349,16 +345,16 @@ } }, "source": [ - "dummy_list = [1,2,3,2,200,16,4,1,0,9.45,45.67,90,12.01,12.02]\n", + "dummy_list = [1,3,5,6,7,9,10,11,13,15]\n", "dummy_list.sort(reverse=True)\n", "print(dummy_list)\n" ], - "execution_count": 16, + "execution_count": 8, "outputs": [ { "output_type": "stream", "text": [ - "[200, 90, 45.67, 16, 12.02, 12.01, 9.45, 4, 3, 2, 2, 1, 1, 0]\n" + "[15, 13, 11, 10, 9, 7, 6, 5, 3, 1]\n" ], "name": "stdout" } @@ -394,18 +390,18 @@ "metadata": { "id": "qZ_OxRW8_6uU", "colab_type": "code", + "outputId": "eaaec73d-5487-46a1-cf8c-c0145b0415b7", "colab": { "base_uri": "https://localhost:8080/", - "height": 202 - }, - "outputId": "31affdcc-a4dd-4c65-f463-55185b30c59e" + "height": 198 + } }, "source": [ - "dummy_list = [1,2,3,2,200,16,4,1.0,9.5,45.67,90,12.01,12.02]\n", - "dummy_list.remove(5) # 5 is not in this list\n", + "dummy_list = [1,3,5,6,7,9,10,11,13,15]\n", + "dummy_list.remove(20) # 20 is not in this list\n", "print(dummy_list)" ], - "execution_count": 18, + "execution_count": 9, "outputs": [ { "output_type": "error", @@ -414,7 +410,7 @@ "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mdummy_list\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m200\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m16\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1.0\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m9.5\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m45.67\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m90\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m12.01\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m12.02\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mdummy_list\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mremove\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# 5 is not in this list\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdummy_list\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mdummy_list\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m6\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m7\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m9\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m11\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m13\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m15\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mdummy_list\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mremove\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m20\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# 20 is not in this list\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdummy_list\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mValueError\u001b[0m: list.remove(x): x not in list" ] } @@ -435,18 +431,18 @@ "metadata": { "id": "aMyo1gmRrVHo", "colab_type": "code", + "outputId": "fc3b6fec-77b7-45b2-cd66-96fcc47235b4", "colab": { "base_uri": "https://localhost:8080/", - "height": 185 - }, - "outputId": "2d12d481-d82b-47de-a0b5-4f6fcef8ff1a" + "height": 181 + } }, "source": [ "# Let's play: try doing the same with x > len(dummy_list) + 1 and see what you get\n", - "dummy_list.remove(15) #15 is not in this list\n", + "dummy_list.remove(12) #12 is not in this list\n", "print(dummy_list)" ], - "execution_count": 19, + "execution_count": 11, "outputs": [ { "output_type": "error", @@ -455,7 +451,7 @@ "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdummy_list\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mremove\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m15\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m#15 is not in this list\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdummy_list\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdummy_list\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mremove\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m12\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m#12 is not in this list\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdummy_list\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mValueError\u001b[0m: list.remove(x): x not in list" ] } @@ -476,17 +472,17 @@ "metadata": { "id": "qBC8lKpLrtJW", "colab_type": "code", + "outputId": "c98cf323-fd13-4123-e0c6-ae27e9ef25e5", "colab": { "base_uri": "https://localhost:8080/", "height": 34 - }, - "outputId": "a22a54a7-5700-41ce-b51d-fd4250684ffc" + } }, "source": [ "dummy_list.clear()\n", "print(dummy_list)" ], - "execution_count": 20, + "execution_count": 12, "outputs": [ { "output_type": "stream",