diff --git a/anujdeep.ipynb b/anujdeep.ipynb index 9e2543a..7287dc1 100644 --- a/anujdeep.ipynb +++ b/anujdeep.ipynb @@ -1,32 +1,520 @@ { - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "anujdeep.ipynb", + "version": "0.3.2", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + } }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.5.2" - } - }, - "nbformat": 4, - "nbformat_minor": 2 + "cells": [ + { + "metadata": { + "id": "3-DtSAmpwzSJ", + "colab_type": "code", + "colab": {} + }, + "cell_type": "code", + "source": [ + "dummy_list=[]\n", + "l1=[2,4,6,1,5]\n", + "dummy_list=l1" + ], + "execution_count": 0, + "outputs": [] + }, + { + "metadata": { + "id": "WD_b8oYg-V4o", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "7aa87ad3-8b2e-45cd-960a-f745df19f899" + }, + "cell_type": "code", + "source": [ + "dummy_list=[2,4,6,1,5]\n", + "print(dummy_list)" + ], + "execution_count": 6, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[2, 4, 6, 1, 5]\n" + ], + "name": "stdout" + } + ] + }, + { + "metadata": { + "id": "A5CzjuyH_BIQ", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "59052fca-3f8a-463d-bf7d-0d03600e7dee" + }, + "cell_type": "code", + "source": [ + "dummy_list.reverse()\n", + "print(dummy_list)" + ], + "execution_count": 3, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[5, 1, 6, 4, 2]\n" + ], + "name": "stdout" + } + ] + }, + { + "metadata": { + "id": "kXTXgUBJD16-", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "f2323a96-717b-4181-ccf7-0a159d092ba3" + }, + "cell_type": "code", + "source": [ + "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": 8, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[6, 5, 4, 2, 1, 2, 200, 16, 4, 1, 0, 9.45, 45.67, 90, 12.01, 12.02]\n" + ], + "name": "stdout" + } + ] + }, + { + "metadata": { + "id": "3XEQXQRwIppj", + "colab_type": "code", + "colab": {} + }, + "cell_type": "code", + "source": [ + "dummy_dict={}\n", + "dummy_dict[0]=1\n", + "dummy_dict[1]=dummy_list.count(1)\n", + "dummy_dict[2]=dummy_list.count(2)\n", + "dummy_dict[4]=dummy_list.count(4)\n", + "dummy_dict[5]=dummy_list.count(5)\n", + "dummy_dict[6]=dummy_list.count(6)\n", + "dummy_dict[9.45]=dummy_list.count(9.45)\n", + "dummy_dict[12.01]=dummy_list.count(12.01)\n", + "dummy_dict[12.02]=dummy_list.count(12.02)\n", + "dummy_dict[16]=dummy_list.count(16)\n", + "dummy_dict[45.67]=dummy_list.count(45.67)\n", + "dummy_dict[90]=dummy_list.count(90)\n", + "dummy_dict[200]=dummy_list.count(200)" + ], + "execution_count": 0, + "outputs": [] + }, + { + "metadata": { + "id": "7YmZBXrSJL0I", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "386a117f-d2a5-43d6-a228-914e65fb8ab2" + }, + "cell_type": "code", + "source": [ + "print(dummy_dict)" + ], + "execution_count": 10, + "outputs": [ + { + "output_type": "stream", + "text": [ + "{0: 1, 1: 2, 2: 2, 4: 2, 5: 1, 6: 1, 9.45: 1, 12.01: 1, 12.02: 1, 16: 1, 45.67: 1, 90: 1, 200: 1}\n" + ], + "name": "stdout" + } + ] + }, + { + "metadata": { + "id": "GvYsFlqdJM8R", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 52 + }, + "outputId": "b666ed3c-ae56-44bc-92c2-59ae7e314d04" + }, + "cell_type": "code", + "source": [ + "dummy_list.sort()\n", + "print(dummy_list)\n", + "dummy_list.reverse()\n", + "print(dummy_list)" + ], + "execution_count": 11, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[0, 1, 1, 2, 2, 4, 4, 5, 6, 9.45, 12.01, 12.02, 16, 45.67, 90, 200]\n", + "[200, 90, 45.67, 16, 12.02, 12.01, 9.45, 6, 5, 4, 4, 2, 2, 1, 1, 0]\n" + ], + "name": "stdout" + } + ] + }, + { + "metadata": { + "id": "3-8U_ptuJt-u", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "778c8142-b200-4009-bdd0-6a4e1f09b4c8" + }, + "cell_type": "code", + "source": [ + "x=200\n", + "dummy_list.remove(x)\n", + "print(dummy_list)" + ], + "execution_count": 12, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[90, 45.67, 16, 12.02, 12.01, 9.45, 6, 5, 4, 4, 2, 2, 1, 1, 0]\n" + ], + "name": "stdout" + } + ] + }, + { + "metadata": { + "id": "1WcrUYhRJ1_0", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "f25481e5-3b40-4b7e-ef33-2533e33fc929" + }, + "cell_type": "code", + "source": [ + "i=3\n", + "dummy_list.pop(i)\n", + "print(dummy_list)" + ], + "execution_count": 13, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[90, 45.67, 16, 12.01, 9.45, 6, 5, 4, 4, 2, 2, 1, 1, 0]\n" + ], + "name": "stdout" + } + ] + }, + { + "metadata": { + "id": "5JEnJABJKAxf", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "2542fbaa-4903-45fc-970b-ae7a22fd2ffc" + }, + "cell_type": "code", + "source": [ + "dummy_list.clear()\n", + "print(dummy_list)" + ], + "execution_count": 14, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[]\n" + ], + "name": "stdout" + } + ] + }, + { + "metadata": { + "id": "JMLLf0GCKeVK", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 207 + }, + "outputId": "8f51b488-02a8-4fea-cfe7-33d039cc518b" + }, + "cell_type": "code", + "source": [ + "import numpy as np\n", + "a=np.linspace(-1.3,2.5,64)\n", + "print(a)" + ], + "execution_count": 16, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[-1.3 -1.23968254 -1.17936508 -1.11904762 -1.05873016 -0.9984127\n", + " -0.93809524 -0.87777778 -0.81746032 -0.75714286 -0.6968254 -0.63650794\n", + " -0.57619048 -0.51587302 -0.45555556 -0.3952381 -0.33492063 -0.27460317\n", + " -0.21428571 -0.15396825 -0.09365079 -0.03333333 0.02698413 0.08730159\n", + " 0.14761905 0.20793651 0.26825397 0.32857143 0.38888889 0.44920635\n", + " 0.50952381 0.56984127 0.63015873 0.69047619 0.75079365 0.81111111\n", + " 0.87142857 0.93174603 0.99206349 1.05238095 1.11269841 1.17301587\n", + " 1.23333333 1.29365079 1.35396825 1.41428571 1.47460317 1.53492063\n", + " 1.5952381 1.65555556 1.71587302 1.77619048 1.83650794 1.8968254\n", + " 1.95714286 2.01746032 2.07777778 2.13809524 2.1984127 2.25873016\n", + " 2.31904762 2.37936508 2.43968254 2.5 ]\n" + ], + "name": "stdout" + } + ] + }, + { + "metadata": { + "id": "kKgAs3lWM4C1", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "1addc4ee-5eed-4fc3-bf53-f088982ffaf7" + }, + "cell_type": "code", + "source": [ + "x = np.array([1.0, 2.0, 3.0])\n", + "y = np.resize(x, 15)\n", + "print(y)" + ], + "execution_count": 18, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[1. 2. 3. 1. 2. 3. 1. 2. 3. 1. 2. 3. 1. 2. 3.]\n" + ], + "name": "stdout" + } + ] + }, + { + "metadata": { + "id": "vLs0F-a_NHYy", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "32e7ae19-f259-4646-ad73-c52c6a4c1165" + }, + "cell_type": "code", + "source": [ + "a=np.arange(20)\n", + "print(a[a%2!=0])" + ], + "execution_count": 19, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[ 1 3 5 7 9 11 13 15 17 19]\n" + ], + "name": "stdout" + } + ] + }, + { + "metadata": { + "id": "RMDyUcP1NclY", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "caaee8c4-c9bc-459a-ce2a-76b129150115" + }, + "cell_type": "code", + "source": [ + "a = np.array([1,2,3,2,3,4,3,4,5,6])\n", + "b = np.array([7,2,10,2,7,4,9,4,9,8])\n", + "print(np.intersect1d(a,b))" + ], + "execution_count": 21, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[2 4]\n" + ], + "name": "stdout" + } + ] + }, + { + "metadata": { + "id": "bIj1tqBfOD2w", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 52 + }, + "outputId": "9c17d2b3-c37e-4376-aa68-6c66a1c82cd1" + }, + "cell_type": "code", + "source": [ + "a=np.arange(10).reshape(2,5)\n", + "print(a)" + ], + "execution_count": 23, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[[0 1 2 3 4]\n", + " [5 6 7 8 9]]\n" + ], + "name": "stdout" + } + ] + }, + { + "metadata": { + "id": "tzIqo7cdPIw1", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 52 + }, + "outputId": "9183a01a-b032-43b7-9913-01fc9e00a268" + }, + "cell_type": "code", + "source": [ + "a = [1, 2, 3, 4, 5, 6, 7, 8, 9]\n", + "a=np.array(a)\n", + "print(a)\n", + "a=list(a)\n", + "print(a)" + ], + "execution_count": 25, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[1 2 3 4 5 6 7 8 9]\n", + "[1, 2, 3, 4, 5, 6, 7, 8, 9]\n" + ], + "name": "stdout" + } + ] + }, + { + "metadata": { + "id": "mMUXSLyKPd5Y", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 190 + }, + "outputId": "de3ef6a5-debb-4b1a-dd27-f1ee45615d88" + }, + "cell_type": "code", + "source": [ + "b=np.zeros((10,10))\n", + "b[0,:]=1\n", + "b[9,:]=1\n", + "b[:,0]=1\n", + "b[:,9]=1\n", + "print(b)" + ], + "execution_count": 26, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[[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", + " [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", + " [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", + " [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]]\n" + ], + "name": "stdout" + } + ] + }, + { + "metadata": { + "id": "F2rmplzbWixn", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 190 + }, + "outputId": "be727ff8-c201-456f-f9cf-9ee6e85e295c" + }, + "cell_type": "code", + "source": [ + "a=np.array(([1,0]*5+[0,1]*5)*5).reshape(10,10)\n", + "print(a)" + ], + "execution_count": 29, + "outputs": [ + { + "output_type": "stream", + "text": [ + "[[1 0 1 0 1 0 1 0 1 0]\n", + " [0 1 0 1 0 1 0 1 0 1]\n", + " [1 0 1 0 1 0 1 0 1 0]\n", + " [0 1 0 1 0 1 0 1 0 1]\n", + " [1 0 1 0 1 0 1 0 1 0]\n", + " [0 1 0 1 0 1 0 1 0 1]\n", + " [1 0 1 0 1 0 1 0 1 0]\n", + " [0 1 0 1 0 1 0 1 0 1]\n", + " [1 0 1 0 1 0 1 0 1 0]\n", + " [0 1 0 1 0 1 0 1 0 1]]\n" + ], + "name": "stdout" + } + ] + } + ] }