Created
May 12, 2020 09:50
-
-
Save HarshCasper/ef20c75889d98cc5353ffef8bccae383 to your computer and use it in GitHub Desktop.
Mathematical Operations using Numpy.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "Mathematical Operations using Numpy.ipynb", | |
"provenance": [], | |
"authorship_tag": "ABX9TyOlv+DJj1VhoGRUWjf+PLyd", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/HarshCasper/ef20c75889d98cc5353ffef8bccae383/mathematical-operations-using-numpy.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "DbykOKDBjHZi", | |
"colab_type": "code", | |
"outputId": "7c1de6aa-08b1-4586-937d-b8fd296ab78c", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 34 | |
} | |
}, | |
"source": [ | |
"import numpy as np\n", | |
"arr = np.array([1,2,3,4])\n", | |
"print(arr)" | |
], | |
"execution_count": 0, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"[1 2 3 4]\n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "ubEzKoo4kOEl", | |
"colab_type": "code", | |
"outputId": "8a4fd214-cee1-414e-eb76-1e719954400d", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 34 | |
} | |
}, | |
"source": [ | |
"# Adding to the Array\n", | |
"print(arr+5)" | |
], | |
"execution_count": 0, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"[6 7 8 9]\n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "R8fal3DzlIdv", | |
"colab_type": "code", | |
"outputId": "79fae47d-9624-46f8-a411-3a499dedcfa3", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 34 | |
} | |
}, | |
"source": [ | |
"# Subtracting from the Array\n", | |
"print(arr-3)" | |
], | |
"execution_count": 0, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"[-2 -1 0 1]\n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "CbgCHXtGlLup", | |
"colab_type": "code", | |
"outputId": "98a3b048-d83a-4ea2-81ce-5341567d14c1", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 34 | |
} | |
}, | |
"source": [ | |
"arr1=np.ones((1,1))\n", | |
"print(arr+arr1)" | |
], | |
"execution_count": 0, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"[[2. 3. 4. 5.]]\n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "aV8ETIYHlRwn", | |
"colab_type": "code", | |
"outputId": "4cfc8cb5-03b3-4bff-e0ee-3388b52151b5", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 50 | |
} | |
}, | |
"source": [ | |
"print(\"The Maximum Element in the Array is %r\" %(np.max(arr)))\n", | |
"print(\"The Minimum Element in the Array is %r\" %(np.min(arr)))" | |
], | |
"execution_count": 0, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"The Maximum Element in the Array is 4\n", | |
"The Minimum Element in the Array is 1\n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "jfVjAn2ZlpMg", | |
"colab_type": "code", | |
"outputId": "2ecfc21e-dc4b-493c-bb17-4a3fab98c2c8", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 50 | |
} | |
}, | |
"source": [ | |
"# Creating a Vertically Stacking Matrix\n", | |
"\n", | |
"arr1=np.array([1,2,3,4,5])\n", | |
"arr2=np.array([6,7,8,9,10])\n", | |
"\n", | |
"np.vstack([arr1,arr2])" | |
], | |
"execution_count": 0, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"array([[ 1, 2, 3, 4, 5],\n", | |
" [ 6, 7, 8, 9, 10]])" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 8 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "f4T0JfBruN37", | |
"colab_type": "code", | |
"outputId": "0159dab6-30e6-401f-c09d-7236296fe7e6", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 34 | |
} | |
}, | |
"source": [ | |
"np.hstack([arr1,arr2])" | |
], | |
"execution_count": 0, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])" | |
] | |
}, | |
"metadata": { | |
"tags": [] | |
}, | |
"execution_count": 9 | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment