├── 00_Python Basics ├── .ipynb_checkpoints │ ├── 01_Python Print Statement-checkpoint.ipynb │ ├── 02_Variables and Data Types-checkpoint.ipynb │ ├── 03_Getting Values from User-checkpoint.ipynb │ ├── 04_Type Conversion-checkpoint.ipynb │ └── 05_First Program in Python-checkpoint.ipynb ├── 01_Python Print Statement.ipynb ├── 02_Variables and Data Types.ipynb ├── 03_Getting Values from User.ipynb ├── 04_Type Conversion.ipynb └── 05_First Program in Python.ipynb ├── 01_While Loop, List, String ├── .ipynb_checkpoints │ └── 1_While Loop, List and String-checkpoint.ipynb └── 1_While Loop, List and String.ipynb ├── 02_For Loop, Dictionary, Tuple, Set ├── .ipynb_checkpoints │ └── 2_For loop, Dictionary, Tuple and Sets-checkpoint.ipynb └── 2_For loop, Dictionary, Tuple and Sets.ipynb ├── 03_Object Oriented Programming ├── .ipynb_checkpoints │ └── 3_Object Orientation-checkpoint.ipynb └── 3_Object Orientation.ipynb ├── 04_Functions, Higher Order Functions ├── .ipynb_checkpoints │ └── 4_Functions-checkpoint.ipynb └── 4_Functions.ipynb ├── 05_Modules, Packages, PIP ├── .ipynb_checkpoints │ └── 5_Modules and Packages-checkpoint.ipynb ├── 5_Modules and Packages.ipynb ├── main.py └── mathematics-meme │ ├── LICENSE.txt │ ├── README.rst │ ├── __pycache__ │ └── maths.cpython-310.pyc │ ├── dist │ └── mathematics-meme-0.2.tar.gz │ ├── setup.cfg │ ├── setup.py │ └── src │ ├── descriptive │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-310.pyc │ │ └── dstatistics.cpython-310.pyc │ └── dstatistics.py │ ├── inferential │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-310.pyc │ │ └── istatitstics.cpython-310.pyc │ └── istatitstics.py │ ├── mathematics_meme.egg-info │ ├── PKG-INFO │ ├── SOURCES.txt │ ├── dependency_links.txt │ └── top_level.txt │ └── maths.py ├── 06_Virtual Environment, Flask, Web Scrapping └── model_building │ ├── application.py │ ├── main.py │ └── templates │ └── index.html ├── 07_Building API, Python with MongoDB Database └── model_building │ ├── app.py │ ├── main.py │ └── templates │ └── index.html ├── 08_Statistics with NumPy ├── .ipynb_checkpoints │ └── 8_NumPy-checkpoint.ipynb ├── 8_NumPy.ipynb └── NumPy Resources │ ├── NumPy Books │ └── NumPy Cookbook, Second Edition.pdf │ ├── NumPy Cheat Sheet │ ├── Numpy_Python_Cheat_Sheet.pdf │ ├── numpy-cheat-sheet.pdf │ └── numpy.pdf │ ├── NumPy Practice Questions │ ├── 1-100 NumPy Exercises for Data Analysis.pdf │ ├── 2-NumPy Exercise 90 Questions.pdf │ ├── 3-Extras From Python to Numpy.pdf │ └── 4-Advance Numpy Python.pdf │ ├── NumPy Reference or Documentation │ ├── NumPy Reference 1.pdf │ └── NumPy Reference 2.pdf │ ├── Reading Assignment-Beyond Numpy Arrays in Python.pdf │ └── Reading Assignment-NumPy project governance.pdf ├── 09_Data Analysis with Pandas ├── .ipynb_checkpoints │ └── 9_Pandas-checkpoint.ipynb ├── 9_Pandas.ipynb ├── Pandas Books │ ├── Learning pandas.pdf │ └── Mastering Pandas.pdf ├── nyc_weather.csv ├── stock_data.csv ├── stocks_weather.xlsx ├── weather_by_cities.csv ├── weather_data.csv ├── weather_data.xlsx ├── weather_data2.csv └── weather_datamissing.csv ├── 10_Data Visualization with Matplotlib ├── .ipynb_checkpoints │ └── 10_Pandas and Matplotlib-checkpoint.ipynb ├── 10_Pandas and Matplotlib.ipynb ├── nyc_weather.csv ├── stock_data.csv ├── stocks_weather.xlsx ├── weather_by_cities.csv ├── weather_data.csv ├── weather_data.xlsx ├── weather_data2.csv └── weather_datamissing.csv ├── 11_Projects ├── .ipynb_checkpoints │ └── 11_EDA Project-checkpoint.ipynb ├── 11_EDA Project.ipynb └── titanic.csv ├── README.md └── images ├── header.png ├── instructorhimanshu.png └── notion.gif /00_Python Basics/.ipynb_checkpoints/01_Python Print Statement-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "111b44ac", 6 | "metadata": {}, 7 | "source": [ 8 | "# Print Statement" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "368f7958", 15 | "metadata": {}, 16 | "outputs": [ 17 | { 18 | "name": "stdout", 19 | "output_type": "stream", 20 | "text": [ 21 | "Hello World\n" 22 | ] 23 | } 24 | ], 25 | "source": [ 26 | "print(\"Hello World\")" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "a3096f5d", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "name": "stdout", 37 | "output_type": "stream", 38 | "text": [ 39 | "Hello\n", 40 | "World\n" 41 | ] 42 | } 43 | ], 44 | "source": [ 45 | "print(\"Hello\\nWorld\") # new line character" 46 | ] 47 | }, 48 | { 49 | "cell_type": "code", 50 | "execution_count": 3, 51 | "id": "c0e151ba", 52 | "metadata": {}, 53 | "outputs": [ 54 | { 55 | "name": "stdout", 56 | "output_type": "stream", 57 | "text": [ 58 | "Hello\tWorld\n" 59 | ] 60 | } 61 | ], 62 | "source": [ 63 | "print(\"Hello\\tWorld\") # horizontal tab" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 4, 69 | "id": "e2925fe6", 70 | "metadata": {}, 71 | "outputs": [ 72 | { 73 | "name": "stdout", 74 | "output_type": "stream", 75 | "text": [ 76 | "\"Hello\"\n" 77 | ] 78 | } 79 | ], 80 | "source": [ 81 | "print(\"\\\"Hello\\\"\")" 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": 5, 87 | "id": "2d6eda53", 88 | "metadata": {}, 89 | "outputs": [ 90 | { 91 | "name": "stdout", 92 | "output_type": "stream", 93 | "text": [ 94 | "\\Hello\\\n" 95 | ] 96 | } 97 | ], 98 | "source": [ 99 | "print(\"\\\\Hello\\\\\")" 100 | ] 101 | }, 102 | { 103 | "cell_type": "markdown", 104 | "id": "6cd88fd3", 105 | "metadata": {}, 106 | "source": [ 107 | "# Questions\n", 108 | "\n", 109 | "**Print the following output**" 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": 7, 115 | "id": "2a2c3e4c", 116 | "metadata": {}, 117 | "outputs": [ 118 | { 119 | "name": "stdout", 120 | "output_type": "stream", 121 | "text": [ 122 | "Himanshu\n", 123 | "\tMasterDexter\n", 124 | "\t\tIndia\n" 125 | ] 126 | } 127 | ], 128 | "source": [ 129 | "print(\"Himanshu\\n\\tMasterDexter\\n\\t\\tIndia\")" 130 | ] 131 | }, 132 | { 133 | "cell_type": "code", 134 | "execution_count": null, 135 | "id": "ca5ad004", 136 | "metadata": {}, 137 | "outputs": [], 138 | "source": [ 139 | "*\n", 140 | "**\n", 141 | "***" 142 | ] 143 | }, 144 | { 145 | "cell_type": "code", 146 | "execution_count": 8, 147 | "id": "81f38efd", 148 | "metadata": {}, 149 | "outputs": [ 150 | { 151 | "name": "stdout", 152 | "output_type": "stream", 153 | "text": [ 154 | "*\n", 155 | "**\n", 156 | "***\n" 157 | ] 158 | } 159 | ], 160 | "source": [ 161 | "print(\"*\\n**\\n***\")" 162 | ] 163 | }, 164 | { 165 | "cell_type": "code", 166 | "execution_count": null, 167 | "id": "43e9f2fc", 168 | "metadata": {}, 169 | "outputs": [], 170 | "source": [ 171 | "--4--*\n", 172 | "*---8---*\n", 173 | "--4--*" 174 | ] 175 | }, 176 | { 177 | "cell_type": "code", 178 | "execution_count": null, 179 | "id": "1db54109", 180 | "metadata": {}, 181 | "outputs": [], 182 | "source": [ 183 | " *\n", 184 | "* *\n", 185 | " *" 186 | ] 187 | }, 188 | { 189 | "cell_type": "code", 190 | "execution_count": 9, 191 | "id": "e2b43488", 192 | "metadata": {}, 193 | "outputs": [ 194 | { 195 | "name": "stdout", 196 | "output_type": "stream", 197 | "text": [ 198 | " *\n", 199 | "*\t*\n", 200 | " *\n" 201 | ] 202 | } 203 | ], 204 | "source": [ 205 | "print(\" *\\n*\\t*\\n *\")" 206 | ] 207 | } 208 | ], 209 | "metadata": { 210 | "kernelspec": { 211 | "display_name": "Python 3 (ipykernel)", 212 | "language": "python", 213 | "name": "python3" 214 | }, 215 | "language_info": { 216 | "codemirror_mode": { 217 | "name": "ipython", 218 | "version": 3 219 | }, 220 | "file_extension": ".py", 221 | "mimetype": "text/x-python", 222 | "name": "python", 223 | "nbconvert_exporter": "python", 224 | "pygments_lexer": "ipython3", 225 | "version": "3.9.12" 226 | } 227 | }, 228 | "nbformat": 4, 229 | "nbformat_minor": 5 230 | } 231 | -------------------------------------------------------------------------------- /00_Python Basics/.ipynb_checkpoints/02_Variables and Data Types-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "a6331ccf", 6 | "metadata": {}, 7 | "source": [ 8 | "# Variables and Data Types" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": null, 14 | "id": "996e438d", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [] 18 | } 19 | ], 20 | "metadata": { 21 | "kernelspec": { 22 | "display_name": "Python 3 (ipykernel)", 23 | "language": "python", 24 | "name": "python3" 25 | }, 26 | "language_info": { 27 | "codemirror_mode": { 28 | "name": "ipython", 29 | "version": 3 30 | }, 31 | "file_extension": ".py", 32 | "mimetype": "text/x-python", 33 | "name": "python", 34 | "nbconvert_exporter": "python", 35 | "pygments_lexer": "ipython3", 36 | "version": "3.9.12" 37 | } 38 | }, 39 | "nbformat": 4, 40 | "nbformat_minor": 5 41 | } 42 | -------------------------------------------------------------------------------- /00_Python Basics/.ipynb_checkpoints/03_Getting Values from User-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "4536963a", 6 | "metadata": {}, 7 | "source": [ 8 | "# Getting Values from User" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "defd92b5", 15 | "metadata": {}, 16 | "outputs": [ 17 | { 18 | "name": "stdout", 19 | "output_type": "stream", 20 | "text": [ 21 | "10\n", 22 | "10\n" 23 | ] 24 | } 25 | ], 26 | "source": [ 27 | "a = input()\n", 28 | "\n", 29 | "print(a)" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": 2, 35 | "id": "a6ea21fb", 36 | "metadata": {}, 37 | "outputs": [ 38 | { 39 | "name": "stdout", 40 | "output_type": "stream", 41 | "text": [ 42 | "Enter a Number: 100\n", 43 | "100\n" 44 | ] 45 | } 46 | ], 47 | "source": [ 48 | "b = input(\"Enter a Number: \")\n", 49 | "\n", 50 | "print(b)" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": 3, 56 | "id": "c28a7082", 57 | "metadata": {}, 58 | "outputs": [ 59 | { 60 | "name": "stdout", 61 | "output_type": "stream", 62 | "text": [ 63 | "Enter Your Name: Himanshu\n", 64 | "Hello! Himanshu\n" 65 | ] 66 | } 67 | ], 68 | "source": [ 69 | "x = input(\"Enter Your Name: \")\n", 70 | "\n", 71 | "print(\"Hello!\", x)" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 4, 77 | "id": "dfa716e2", 78 | "metadata": {}, 79 | "outputs": [ 80 | { 81 | "name": "stdout", 82 | "output_type": "stream", 83 | "text": [ 84 | "Enter Your Password: 12345\n", 85 | "Your Password is : 12345\n" 86 | ] 87 | } 88 | ], 89 | "source": [ 90 | "password = input(\"Enter Your Password: \")\n", 91 | "\n", 92 | "print(\"Your Password is : \", password)" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": null, 98 | "id": "8d0d6334", 99 | "metadata": {}, 100 | "outputs": [], 101 | "source": [] 102 | } 103 | ], 104 | "metadata": { 105 | "kernelspec": { 106 | "display_name": "Python 3 (ipykernel)", 107 | "language": "python", 108 | "name": "python3" 109 | }, 110 | "language_info": { 111 | "codemirror_mode": { 112 | "name": "ipython", 113 | "version": 3 114 | }, 115 | "file_extension": ".py", 116 | "mimetype": "text/x-python", 117 | "name": "python", 118 | "nbconvert_exporter": "python", 119 | "pygments_lexer": "ipython3", 120 | "version": "3.9.12" 121 | } 122 | }, 123 | "nbformat": 4, 124 | "nbformat_minor": 5 125 | } 126 | -------------------------------------------------------------------------------- /00_Python Basics/.ipynb_checkpoints/04_Type Conversion-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "505fc528", 6 | "metadata": {}, 7 | "source": [ 8 | "# Type Conversion\n" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "8fc0915d", 15 | "metadata": {}, 16 | "outputs": [ 17 | { 18 | "ename": "TypeError", 19 | "evalue": "unsupported operand type(s) for +: 'int' and 'str'", 20 | "output_type": "error", 21 | "traceback": [ 22 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 23 | "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", 24 | "Input \u001b[1;32mIn [1]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;241;43m10\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mA\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\n", 25 | "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'int' and 'str'" 26 | ] 27 | } 28 | ], 29 | "source": [ 30 | "10 + \"A\"" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": 2, 36 | "id": "f0e39b61", 37 | "metadata": {}, 38 | "outputs": [ 39 | { 40 | "name": "stdout", 41 | "output_type": "stream", 42 | "text": [ 43 | "\n", 44 | "\n" 45 | ] 46 | }, 47 | { 48 | "ename": "TypeError", 49 | "evalue": "unsupported operand type(s) for +: 'int' and 'str'", 50 | "output_type": "error", 51 | "traceback": [ 52 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 53 | "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", 54 | "Input \u001b[1;32mIn [2]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;28mtype\u001b[39m(a))\n\u001b[0;32m 6\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;28mtype\u001b[39m(b))\n\u001b[1;32m----> 8\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43ma\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mb\u001b[49m)\n", 55 | "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'int' and 'str'" 56 | ] 57 | } 58 | ], 59 | "source": [ 60 | "a = 10\n", 61 | "\n", 62 | "b = \"20\"\n", 63 | "\n", 64 | "print(type(a))\n", 65 | "print(type(b))\n", 66 | "\n", 67 | "print(a + b)" 68 | ] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": 3, 73 | "id": "b773726d", 74 | "metadata": {}, 75 | "outputs": [ 76 | { 77 | "name": "stdout", 78 | "output_type": "stream", 79 | "text": [ 80 | "\n", 81 | "\n", 82 | "30\n", 83 | "\n" 84 | ] 85 | } 86 | ], 87 | "source": [ 88 | "a = 10\n", 89 | "\n", 90 | "b = \"20\"\n", 91 | "\n", 92 | "print(type(a))\n", 93 | "print(type(b))\n", 94 | "\n", 95 | "c = int(b)\n", 96 | "\n", 97 | "print(a + c)\n", 98 | "\n", 99 | "print(type(c))" 100 | ] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "execution_count": 4, 105 | "id": "4b85f5b2", 106 | "metadata": {}, 107 | "outputs": [ 108 | { 109 | "ename": "ValueError", 110 | "evalue": "invalid literal for int() with base 10: 'A'", 111 | "output_type": "error", 112 | "traceback": [ 113 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 114 | "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", 115 | "Input \u001b[1;32mIn [4]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m a \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m10\u001b[39m\n\u001b[0;32m 3\u001b[0m b \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mA\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m----> 5\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;28;43mint\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mb\u001b[49m\u001b[43m)\u001b[49m)\n", 116 | "\u001b[1;31mValueError\u001b[0m: invalid literal for int() with base 10: 'A'" 117 | ] 118 | } 119 | ], 120 | "source": [ 121 | "a = 10\n", 122 | "\n", 123 | "b = \"A\"\n", 124 | "\n", 125 | "print(int(b))" 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "execution_count": 5, 131 | "id": "bc000d1c", 132 | "metadata": {}, 133 | "outputs": [ 134 | { 135 | "name": "stdout", 136 | "output_type": "stream", 137 | "text": [ 138 | "\n", 139 | "\n", 140 | "\n", 141 | "\n", 142 | "100200\n" 143 | ] 144 | } 145 | ], 146 | "source": [ 147 | "a = 100\n", 148 | "\n", 149 | "b = 200\n", 150 | "\n", 151 | "print(type(a))\n", 152 | "print(type(b))\n", 153 | "\n", 154 | "c = str(a)\n", 155 | "d = str(b)\n", 156 | "\n", 157 | "print(type(c))\n", 158 | "print(type(d))\n", 159 | "\n", 160 | "print(c + d)" 161 | ] 162 | }, 163 | { 164 | "cell_type": "code", 165 | "execution_count": 6, 166 | "id": "712b3f87", 167 | "metadata": {}, 168 | "outputs": [ 169 | { 170 | "data": { 171 | "text/plain": [ 172 | "'AB'" 173 | ] 174 | }, 175 | "execution_count": 6, 176 | "metadata": {}, 177 | "output_type": "execute_result" 178 | } 179 | ], 180 | "source": [ 181 | "\"A\" + \"B\"" 182 | ] 183 | }, 184 | { 185 | "cell_type": "code", 186 | "execution_count": 7, 187 | "id": "7c2c41bf", 188 | "metadata": {}, 189 | "outputs": [ 190 | { 191 | "data": { 192 | "text/plain": [ 193 | "'India is the Best'" 194 | ] 195 | }, 196 | "execution_count": 7, 197 | "metadata": {}, 198 | "output_type": "execute_result" 199 | } 200 | ], 201 | "source": [ 202 | "\"India\" + \" is the \" + \"Best\"" 203 | ] 204 | }, 205 | { 206 | "cell_type": "code", 207 | "execution_count": 9, 208 | "id": "a9f64522", 209 | "metadata": {}, 210 | "outputs": [ 211 | { 212 | "name": "stdout", 213 | "output_type": "stream", 214 | "text": [ 215 | "10.65\n", 216 | "\n", 217 | "\n", 218 | "10\n" 219 | ] 220 | } 221 | ], 222 | "source": [ 223 | "a = 10.65\n", 224 | "\n", 225 | "print(a)\n", 226 | "print(type(a))\n", 227 | "\n", 228 | "b = int(a)\n", 229 | "\n", 230 | "print(type(b))\n", 231 | "print(b)" 232 | ] 233 | }, 234 | { 235 | "cell_type": "code", 236 | "execution_count": null, 237 | "id": "f1dccafe", 238 | "metadata": {}, 239 | "outputs": [], 240 | "source": [] 241 | } 242 | ], 243 | "metadata": { 244 | "kernelspec": { 245 | "display_name": "Python 3 (ipykernel)", 246 | "language": "python", 247 | "name": "python3" 248 | }, 249 | "language_info": { 250 | "codemirror_mode": { 251 | "name": "ipython", 252 | "version": 3 253 | }, 254 | "file_extension": ".py", 255 | "mimetype": "text/x-python", 256 | "name": "python", 257 | "nbconvert_exporter": "python", 258 | "pygments_lexer": "ipython3", 259 | "version": "3.9.12" 260 | } 261 | }, 262 | "nbformat": 4, 263 | "nbformat_minor": 5 264 | } 265 | -------------------------------------------------------------------------------- /00_Python Basics/.ipynb_checkpoints/05_First Program in Python-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "8205f44d", 6 | "metadata": {}, 7 | "source": [ 8 | "# First Program in Python\n", 9 | "\n", 10 | "**Write a program to enter 2 numbers from user and print addition of them**" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 1, 16 | "id": "f67bb325", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "name": "stdout", 21 | "output_type": "stream", 22 | "text": [ 23 | "Enter 1st Number: 10\n", 24 | "Enter 2nd Number: 20\n", 25 | "1020\n" 26 | ] 27 | } 28 | ], 29 | "source": [ 30 | "a = input(\"Enter 1st Number: \")\n", 31 | "b = input(\"Enter 2nd Number: \")\n", 32 | "\n", 33 | "c = a + b\n", 34 | "\n", 35 | "print(c)" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": 2, 41 | "id": "92d08572", 42 | "metadata": {}, 43 | "outputs": [ 44 | { 45 | "name": "stdout", 46 | "output_type": "stream", 47 | "text": [ 48 | "\n" 49 | ] 50 | } 51 | ], 52 | "source": [ 53 | "print(type(a))" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": 3, 59 | "id": "c0a80669", 60 | "metadata": {}, 61 | "outputs": [ 62 | { 63 | "name": "stdout", 64 | "output_type": "stream", 65 | "text": [ 66 | "Enter 1st Number: 10\n", 67 | "Enter 2nd Number: 20\n", 68 | "30\n" 69 | ] 70 | } 71 | ], 72 | "source": [ 73 | "a = int(input(\"Enter 1st Number: \"))\n", 74 | "b = int(input(\"Enter 2nd Number: \"))\n", 75 | "\n", 76 | "c = a + b\n", 77 | "\n", 78 | "print(c)" 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": 4, 84 | "id": "5fc10126", 85 | "metadata": {}, 86 | "outputs": [ 87 | { 88 | "name": "stdout", 89 | "output_type": "stream", 90 | "text": [ 91 | "Enter 1st Number: 10\n", 92 | "Enter 2nd Number: 20\n", 93 | "Addition = 30\n" 94 | ] 95 | } 96 | ], 97 | "source": [ 98 | "a = int(input(\"Enter 1st Number: \"))\n", 99 | "b = int(input(\"Enter 2nd Number: \"))\n", 100 | "\n", 101 | "c = a + b\n", 102 | "\n", 103 | "print(\"Addition =\",c)" 104 | ] 105 | }, 106 | { 107 | "cell_type": "markdown", 108 | "id": "e09fb5fe", 109 | "metadata": {}, 110 | "source": [ 111 | "# Questions\n", 112 | "\n", 113 | "**Write a program to enter 2 numbers from user and print addition, subtraction, multiplication and division.**" 114 | ] 115 | }, 116 | { 117 | "cell_type": "code", 118 | "execution_count": null, 119 | "id": "cad2ce42", 120 | "metadata": {}, 121 | "outputs": [], 122 | "source": [] 123 | } 124 | ], 125 | "metadata": { 126 | "kernelspec": { 127 | "display_name": "Python 3 (ipykernel)", 128 | "language": "python", 129 | "name": "python3" 130 | }, 131 | "language_info": { 132 | "codemirror_mode": { 133 | "name": "ipython", 134 | "version": 3 135 | }, 136 | "file_extension": ".py", 137 | "mimetype": "text/x-python", 138 | "name": "python", 139 | "nbconvert_exporter": "python", 140 | "pygments_lexer": "ipython3", 141 | "version": "3.9.12" 142 | } 143 | }, 144 | "nbformat": 4, 145 | "nbformat_minor": 5 146 | } 147 | -------------------------------------------------------------------------------- /00_Python Basics/01_Python Print Statement.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "111b44ac", 6 | "metadata": {}, 7 | "source": [ 8 | "# Print Statement" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "368f7958", 15 | "metadata": {}, 16 | "outputs": [ 17 | { 18 | "name": "stdout", 19 | "output_type": "stream", 20 | "text": [ 21 | "Hello World\n" 22 | ] 23 | } 24 | ], 25 | "source": [ 26 | "print(\"Hello World\")" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "id": "a3096f5d", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "name": "stdout", 37 | "output_type": "stream", 38 | "text": [ 39 | "Hello\n", 40 | "World\n" 41 | ] 42 | } 43 | ], 44 | "source": [ 45 | "print(\"Hello\\nWorld\") # new line character" 46 | ] 47 | }, 48 | { 49 | "cell_type": "code", 50 | "execution_count": 3, 51 | "id": "c0e151ba", 52 | "metadata": {}, 53 | "outputs": [ 54 | { 55 | "name": "stdout", 56 | "output_type": "stream", 57 | "text": [ 58 | "Hello\tWorld\n" 59 | ] 60 | } 61 | ], 62 | "source": [ 63 | "print(\"Hello\\tWorld\") # horizontal tab" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 4, 69 | "id": "e2925fe6", 70 | "metadata": {}, 71 | "outputs": [ 72 | { 73 | "name": "stdout", 74 | "output_type": "stream", 75 | "text": [ 76 | "\"Hello\"\n" 77 | ] 78 | } 79 | ], 80 | "source": [ 81 | "print(\"\\\"Hello\\\"\")" 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": 5, 87 | "id": "2d6eda53", 88 | "metadata": {}, 89 | "outputs": [ 90 | { 91 | "name": "stdout", 92 | "output_type": "stream", 93 | "text": [ 94 | "\\Hello\\\n" 95 | ] 96 | } 97 | ], 98 | "source": [ 99 | "print(\"\\\\Hello\\\\\")" 100 | ] 101 | }, 102 | { 103 | "cell_type": "markdown", 104 | "id": "6cd88fd3", 105 | "metadata": {}, 106 | "source": [ 107 | "# Questions\n", 108 | "\n", 109 | "**Print the following output**" 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": 7, 115 | "id": "2a2c3e4c", 116 | "metadata": {}, 117 | "outputs": [ 118 | { 119 | "name": "stdout", 120 | "output_type": "stream", 121 | "text": [ 122 | "Himanshu\n", 123 | "\tMasterDexter\n", 124 | "\t\tIndia\n" 125 | ] 126 | } 127 | ], 128 | "source": [ 129 | "print(\"Himanshu\\n\\tMasterDexter\\n\\t\\tIndia\")" 130 | ] 131 | }, 132 | { 133 | "cell_type": "code", 134 | "execution_count": null, 135 | "id": "ca5ad004", 136 | "metadata": {}, 137 | "outputs": [], 138 | "source": [ 139 | "*\n", 140 | "**\n", 141 | "***" 142 | ] 143 | }, 144 | { 145 | "cell_type": "code", 146 | "execution_count": 8, 147 | "id": "81f38efd", 148 | "metadata": {}, 149 | "outputs": [ 150 | { 151 | "name": "stdout", 152 | "output_type": "stream", 153 | "text": [ 154 | "*\n", 155 | "**\n", 156 | "***\n" 157 | ] 158 | } 159 | ], 160 | "source": [ 161 | "print(\"*\\n**\\n***\")" 162 | ] 163 | }, 164 | { 165 | "cell_type": "code", 166 | "execution_count": null, 167 | "id": "43e9f2fc", 168 | "metadata": {}, 169 | "outputs": [], 170 | "source": [ 171 | "--4--*\n", 172 | "*---8---*\n", 173 | "--4--*" 174 | ] 175 | }, 176 | { 177 | "cell_type": "code", 178 | "execution_count": null, 179 | "id": "1db54109", 180 | "metadata": {}, 181 | "outputs": [], 182 | "source": [ 183 | " *\n", 184 | "* *\n", 185 | " *" 186 | ] 187 | }, 188 | { 189 | "cell_type": "code", 190 | "execution_count": 9, 191 | "id": "e2b43488", 192 | "metadata": {}, 193 | "outputs": [ 194 | { 195 | "name": "stdout", 196 | "output_type": "stream", 197 | "text": [ 198 | " *\n", 199 | "*\t*\n", 200 | " *\n" 201 | ] 202 | } 203 | ], 204 | "source": [ 205 | "print(\" *\\n*\\t*\\n *\")" 206 | ] 207 | } 208 | ], 209 | "metadata": { 210 | "kernelspec": { 211 | "display_name": "Python 3 (ipykernel)", 212 | "language": "python", 213 | "name": "python3" 214 | }, 215 | "language_info": { 216 | "codemirror_mode": { 217 | "name": "ipython", 218 | "version": 3 219 | }, 220 | "file_extension": ".py", 221 | "mimetype": "text/x-python", 222 | "name": "python", 223 | "nbconvert_exporter": "python", 224 | "pygments_lexer": "ipython3", 225 | "version": "3.9.12" 226 | } 227 | }, 228 | "nbformat": 4, 229 | "nbformat_minor": 5 230 | } 231 | -------------------------------------------------------------------------------- /00_Python Basics/02_Variables and Data Types.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "a6331ccf", 6 | "metadata": {}, 7 | "source": [ 8 | "# Variables and Data Types" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "996e438d", 15 | "metadata": {}, 16 | "outputs": [ 17 | { 18 | "name": "stdout", 19 | "output_type": "stream", 20 | "text": [ 21 | "10\n" 22 | ] 23 | } 24 | ], 25 | "source": [ 26 | "a = 10\n", 27 | "\n", 28 | "print(a)" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": 2, 34 | "id": "0c6ed733", 35 | "metadata": {}, 36 | "outputs": [ 37 | { 38 | "name": "stdout", 39 | "output_type": "stream", 40 | "text": [ 41 | "10.65\n" 42 | ] 43 | } 44 | ], 45 | "source": [ 46 | "b = 10.65\n", 47 | "\n", 48 | "print(b)" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 3, 54 | "id": "ffc1c9b9", 55 | "metadata": {}, 56 | "outputs": [ 57 | { 58 | "name": "stdout", 59 | "output_type": "stream", 60 | "text": [ 61 | "India\n" 62 | ] 63 | } 64 | ], 65 | "source": [ 66 | "c = \"India\"\n", 67 | "\n", 68 | "print(c)" 69 | ] 70 | }, 71 | { 72 | "cell_type": "markdown", 73 | "id": "d3d5e19b", 74 | "metadata": {}, 75 | "source": [ 76 | "# Data Types\n", 77 | "\n", 78 | "#### type function" 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": 4, 84 | "id": "f4f35f8a", 85 | "metadata": {}, 86 | "outputs": [ 87 | { 88 | "name": "stdout", 89 | "output_type": "stream", 90 | "text": [ 91 | "10\n", 92 | "\n" 93 | ] 94 | } 95 | ], 96 | "source": [ 97 | "a = 10\n", 98 | "\n", 99 | "print(a)\n", 100 | "\n", 101 | "print(type(a))" 102 | ] 103 | }, 104 | { 105 | "cell_type": "code", 106 | "execution_count": 5, 107 | "id": "62b76e6f", 108 | "metadata": {}, 109 | "outputs": [ 110 | { 111 | "name": "stdout", 112 | "output_type": "stream", 113 | "text": [ 114 | "10.65\n", 115 | "\n" 116 | ] 117 | } 118 | ], 119 | "source": [ 120 | "b = 10.65\n", 121 | "\n", 122 | "print(b)\n", 123 | "\n", 124 | "print(type(b))" 125 | ] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "execution_count": 6, 130 | "id": "6255c004", 131 | "metadata": {}, 132 | "outputs": [ 133 | { 134 | "name": "stdout", 135 | "output_type": "stream", 136 | "text": [ 137 | "India\n", 138 | "\n" 139 | ] 140 | } 141 | ], 142 | "source": [ 143 | "c = \"India\"\n", 144 | "\n", 145 | "print(c)\n", 146 | "\n", 147 | "print(type(c))" 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": 7, 153 | "id": "75a61520", 154 | "metadata": {}, 155 | "outputs": [ 156 | { 157 | "name": "stdout", 158 | "output_type": "stream", 159 | "text": [ 160 | "15\n", 161 | "10\n" 162 | ] 163 | } 164 | ], 165 | "source": [ 166 | "a = 10\n", 167 | "\n", 168 | "print(a + 5)\n", 169 | "\n", 170 | "print(a)" 171 | ] 172 | }, 173 | { 174 | "cell_type": "code", 175 | "execution_count": 8, 176 | "id": "942f3876", 177 | "metadata": {}, 178 | "outputs": [ 179 | { 180 | "name": "stdout", 181 | "output_type": "stream", 182 | "text": [ 183 | "15\n" 184 | ] 185 | } 186 | ], 187 | "source": [ 188 | "a = 10\n", 189 | "\n", 190 | "a = a + 5\n", 191 | "\n", 192 | "print(a)" 193 | ] 194 | }, 195 | { 196 | "cell_type": "code", 197 | "execution_count": null, 198 | "id": "bbe65df8", 199 | "metadata": {}, 200 | "outputs": [], 201 | "source": [] 202 | } 203 | ], 204 | "metadata": { 205 | "kernelspec": { 206 | "display_name": "Python 3 (ipykernel)", 207 | "language": "python", 208 | "name": "python3" 209 | }, 210 | "language_info": { 211 | "codemirror_mode": { 212 | "name": "ipython", 213 | "version": 3 214 | }, 215 | "file_extension": ".py", 216 | "mimetype": "text/x-python", 217 | "name": "python", 218 | "nbconvert_exporter": "python", 219 | "pygments_lexer": "ipython3", 220 | "version": "3.9.12" 221 | } 222 | }, 223 | "nbformat": 4, 224 | "nbformat_minor": 5 225 | } 226 | -------------------------------------------------------------------------------- /00_Python Basics/03_Getting Values from User.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "4536963a", 6 | "metadata": {}, 7 | "source": [ 8 | "# Getting Values from User" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "defd92b5", 15 | "metadata": {}, 16 | "outputs": [ 17 | { 18 | "name": "stdout", 19 | "output_type": "stream", 20 | "text": [ 21 | "10\n", 22 | "10\n" 23 | ] 24 | } 25 | ], 26 | "source": [ 27 | "a = input()\n", 28 | "\n", 29 | "print(a)" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": 2, 35 | "id": "a6ea21fb", 36 | "metadata": {}, 37 | "outputs": [ 38 | { 39 | "name": "stdout", 40 | "output_type": "stream", 41 | "text": [ 42 | "Enter a Number: 100\n", 43 | "100\n" 44 | ] 45 | } 46 | ], 47 | "source": [ 48 | "b = input(\"Enter a Number: \")\n", 49 | "\n", 50 | "print(b)" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": 3, 56 | "id": "c28a7082", 57 | "metadata": {}, 58 | "outputs": [ 59 | { 60 | "name": "stdout", 61 | "output_type": "stream", 62 | "text": [ 63 | "Enter Your Name: Himanshu\n", 64 | "Hello! Himanshu\n" 65 | ] 66 | } 67 | ], 68 | "source": [ 69 | "x = input(\"Enter Your Name: \")\n", 70 | "\n", 71 | "print(\"Hello!\", x)" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 4, 77 | "id": "dfa716e2", 78 | "metadata": {}, 79 | "outputs": [ 80 | { 81 | "name": "stdout", 82 | "output_type": "stream", 83 | "text": [ 84 | "Enter Your Password: 12345\n", 85 | "Your Password is : 12345\n" 86 | ] 87 | } 88 | ], 89 | "source": [ 90 | "password = input(\"Enter Your Password: \")\n", 91 | "\n", 92 | "print(\"Your Password is : \", password)" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": null, 98 | "id": "8d0d6334", 99 | "metadata": {}, 100 | "outputs": [], 101 | "source": [] 102 | } 103 | ], 104 | "metadata": { 105 | "kernelspec": { 106 | "display_name": "Python 3 (ipykernel)", 107 | "language": "python", 108 | "name": "python3" 109 | }, 110 | "language_info": { 111 | "codemirror_mode": { 112 | "name": "ipython", 113 | "version": 3 114 | }, 115 | "file_extension": ".py", 116 | "mimetype": "text/x-python", 117 | "name": "python", 118 | "nbconvert_exporter": "python", 119 | "pygments_lexer": "ipython3", 120 | "version": "3.9.12" 121 | } 122 | }, 123 | "nbformat": 4, 124 | "nbformat_minor": 5 125 | } 126 | -------------------------------------------------------------------------------- /00_Python Basics/04_Type Conversion.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "505fc528", 6 | "metadata": {}, 7 | "source": [ 8 | "# Type Conversion\n" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "8fc0915d", 15 | "metadata": {}, 16 | "outputs": [ 17 | { 18 | "ename": "TypeError", 19 | "evalue": "unsupported operand type(s) for +: 'int' and 'str'", 20 | "output_type": "error", 21 | "traceback": [ 22 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 23 | "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", 24 | "Input \u001b[1;32mIn [1]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;241;43m10\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mA\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\n", 25 | "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'int' and 'str'" 26 | ] 27 | } 28 | ], 29 | "source": [ 30 | "10 + \"A\"" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": 2, 36 | "id": "f0e39b61", 37 | "metadata": {}, 38 | "outputs": [ 39 | { 40 | "name": "stdout", 41 | "output_type": "stream", 42 | "text": [ 43 | "\n", 44 | "\n" 45 | ] 46 | }, 47 | { 48 | "ename": "TypeError", 49 | "evalue": "unsupported operand type(s) for +: 'int' and 'str'", 50 | "output_type": "error", 51 | "traceback": [ 52 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 53 | "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", 54 | "Input \u001b[1;32mIn [2]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;28mtype\u001b[39m(a))\n\u001b[0;32m 6\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;28mtype\u001b[39m(b))\n\u001b[1;32m----> 8\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43ma\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mb\u001b[49m)\n", 55 | "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'int' and 'str'" 56 | ] 57 | } 58 | ], 59 | "source": [ 60 | "a = 10\n", 61 | "\n", 62 | "b = \"20\"\n", 63 | "\n", 64 | "print(type(a))\n", 65 | "print(type(b))\n", 66 | "\n", 67 | "print(a + b)" 68 | ] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": 3, 73 | "id": "b773726d", 74 | "metadata": {}, 75 | "outputs": [ 76 | { 77 | "name": "stdout", 78 | "output_type": "stream", 79 | "text": [ 80 | "\n", 81 | "\n", 82 | "30\n", 83 | "\n" 84 | ] 85 | } 86 | ], 87 | "source": [ 88 | "a = 10\n", 89 | "\n", 90 | "b = \"20\"\n", 91 | "\n", 92 | "print(type(a))\n", 93 | "print(type(b))\n", 94 | "\n", 95 | "c = int(b)\n", 96 | "\n", 97 | "print(a + c)\n", 98 | "\n", 99 | "print(type(c))" 100 | ] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "execution_count": 4, 105 | "id": "4b85f5b2", 106 | "metadata": {}, 107 | "outputs": [ 108 | { 109 | "ename": "ValueError", 110 | "evalue": "invalid literal for int() with base 10: 'A'", 111 | "output_type": "error", 112 | "traceback": [ 113 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 114 | "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", 115 | "Input \u001b[1;32mIn [4]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m a \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m10\u001b[39m\n\u001b[0;32m 3\u001b[0m b \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mA\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m----> 5\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;28;43mint\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mb\u001b[49m\u001b[43m)\u001b[49m)\n", 116 | "\u001b[1;31mValueError\u001b[0m: invalid literal for int() with base 10: 'A'" 117 | ] 118 | } 119 | ], 120 | "source": [ 121 | "a = 10\n", 122 | "\n", 123 | "b = \"A\"\n", 124 | "\n", 125 | "print(int(b))" 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "execution_count": 5, 131 | "id": "bc000d1c", 132 | "metadata": {}, 133 | "outputs": [ 134 | { 135 | "name": "stdout", 136 | "output_type": "stream", 137 | "text": [ 138 | "\n", 139 | "\n", 140 | "\n", 141 | "\n", 142 | "100200\n" 143 | ] 144 | } 145 | ], 146 | "source": [ 147 | "a = 100\n", 148 | "\n", 149 | "b = 200\n", 150 | "\n", 151 | "print(type(a))\n", 152 | "print(type(b))\n", 153 | "\n", 154 | "c = str(a)\n", 155 | "d = str(b)\n", 156 | "\n", 157 | "print(type(c))\n", 158 | "print(type(d))\n", 159 | "\n", 160 | "print(c + d)" 161 | ] 162 | }, 163 | { 164 | "cell_type": "code", 165 | "execution_count": 6, 166 | "id": "712b3f87", 167 | "metadata": {}, 168 | "outputs": [ 169 | { 170 | "data": { 171 | "text/plain": [ 172 | "'AB'" 173 | ] 174 | }, 175 | "execution_count": 6, 176 | "metadata": {}, 177 | "output_type": "execute_result" 178 | } 179 | ], 180 | "source": [ 181 | "\"A\" + \"B\"" 182 | ] 183 | }, 184 | { 185 | "cell_type": "code", 186 | "execution_count": 7, 187 | "id": "7c2c41bf", 188 | "metadata": {}, 189 | "outputs": [ 190 | { 191 | "data": { 192 | "text/plain": [ 193 | "'India is the Best'" 194 | ] 195 | }, 196 | "execution_count": 7, 197 | "metadata": {}, 198 | "output_type": "execute_result" 199 | } 200 | ], 201 | "source": [ 202 | "\"India\" + \" is the \" + \"Best\"" 203 | ] 204 | }, 205 | { 206 | "cell_type": "code", 207 | "execution_count": 9, 208 | "id": "a9f64522", 209 | "metadata": {}, 210 | "outputs": [ 211 | { 212 | "name": "stdout", 213 | "output_type": "stream", 214 | "text": [ 215 | "10.65\n", 216 | "\n", 217 | "\n", 218 | "10\n" 219 | ] 220 | } 221 | ], 222 | "source": [ 223 | "a = 10.65\n", 224 | "\n", 225 | "print(a)\n", 226 | "print(type(a))\n", 227 | "\n", 228 | "b = int(a)\n", 229 | "\n", 230 | "print(type(b))\n", 231 | "print(b)" 232 | ] 233 | }, 234 | { 235 | "cell_type": "code", 236 | "execution_count": null, 237 | "id": "f1dccafe", 238 | "metadata": {}, 239 | "outputs": [], 240 | "source": [] 241 | } 242 | ], 243 | "metadata": { 244 | "kernelspec": { 245 | "display_name": "Python 3 (ipykernel)", 246 | "language": "python", 247 | "name": "python3" 248 | }, 249 | "language_info": { 250 | "codemirror_mode": { 251 | "name": "ipython", 252 | "version": 3 253 | }, 254 | "file_extension": ".py", 255 | "mimetype": "text/x-python", 256 | "name": "python", 257 | "nbconvert_exporter": "python", 258 | "pygments_lexer": "ipython3", 259 | "version": "3.9.12" 260 | } 261 | }, 262 | "nbformat": 4, 263 | "nbformat_minor": 5 264 | } 265 | -------------------------------------------------------------------------------- /00_Python Basics/05_First Program in Python.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "8205f44d", 6 | "metadata": {}, 7 | "source": [ 8 | "# First Program in Python\n", 9 | "\n", 10 | "**Write a program to enter 2 numbers from user and print addition of them**" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 1, 16 | "id": "f67bb325", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "name": "stdout", 21 | "output_type": "stream", 22 | "text": [ 23 | "Enter 1st Number: 10\n", 24 | "Enter 2nd Number: 20\n", 25 | "1020\n" 26 | ] 27 | } 28 | ], 29 | "source": [ 30 | "a = input(\"Enter 1st Number: \")\n", 31 | "b = input(\"Enter 2nd Number: \")\n", 32 | "\n", 33 | "c = a + b\n", 34 | "\n", 35 | "print(c)" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": 2, 41 | "id": "92d08572", 42 | "metadata": {}, 43 | "outputs": [ 44 | { 45 | "name": "stdout", 46 | "output_type": "stream", 47 | "text": [ 48 | "\n" 49 | ] 50 | } 51 | ], 52 | "source": [ 53 | "print(type(a))" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": 3, 59 | "id": "c0a80669", 60 | "metadata": {}, 61 | "outputs": [ 62 | { 63 | "name": "stdout", 64 | "output_type": "stream", 65 | "text": [ 66 | "Enter 1st Number: 10\n", 67 | "Enter 2nd Number: 20\n", 68 | "30\n" 69 | ] 70 | } 71 | ], 72 | "source": [ 73 | "a = int(input(\"Enter 1st Number: \"))\n", 74 | "b = int(input(\"Enter 2nd Number: \"))\n", 75 | "\n", 76 | "c = a + b\n", 77 | "\n", 78 | "print(c)" 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": 4, 84 | "id": "5fc10126", 85 | "metadata": {}, 86 | "outputs": [ 87 | { 88 | "name": "stdout", 89 | "output_type": "stream", 90 | "text": [ 91 | "Enter 1st Number: 10\n", 92 | "Enter 2nd Number: 20\n", 93 | "Addition = 30\n" 94 | ] 95 | } 96 | ], 97 | "source": [ 98 | "a = int(input(\"Enter 1st Number: \"))\n", 99 | "b = int(input(\"Enter 2nd Number: \"))\n", 100 | "\n", 101 | "c = a + b\n", 102 | "\n", 103 | "print(\"Addition =\",c)" 104 | ] 105 | }, 106 | { 107 | "cell_type": "markdown", 108 | "id": "e09fb5fe", 109 | "metadata": {}, 110 | "source": [ 111 | "# Questions\n", 112 | "\n", 113 | "**Write a program to enter 2 numbers from user and print addition, subtraction, multiplication and division.**" 114 | ] 115 | }, 116 | { 117 | "cell_type": "code", 118 | "execution_count": null, 119 | "id": "cad2ce42", 120 | "metadata": {}, 121 | "outputs": [], 122 | "source": [] 123 | } 124 | ], 125 | "metadata": { 126 | "kernelspec": { 127 | "display_name": "Python 3 (ipykernel)", 128 | "language": "python", 129 | "name": "python3" 130 | }, 131 | "language_info": { 132 | "codemirror_mode": { 133 | "name": "ipython", 134 | "version": 3 135 | }, 136 | "file_extension": ".py", 137 | "mimetype": "text/x-python", 138 | "name": "python", 139 | "nbconvert_exporter": "python", 140 | "pygments_lexer": "ipython3", 141 | "version": "3.9.12" 142 | } 143 | }, 144 | "nbformat": 4, 145 | "nbformat_minor": 5 146 | } 147 | -------------------------------------------------------------------------------- /04_Functions, Higher Order Functions/.ipynb_checkpoints/4_Functions-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "d9d3b384", 6 | "metadata": {}, 7 | "source": [ 8 | "# Functions" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "243d1342", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "def myfunction(): # definition of a function\n", 19 | " print(\"Hey\")" 20 | ] 21 | }, 22 | { 23 | "cell_type": "code", 24 | "execution_count": 2, 25 | "id": "e16c3fe1", 26 | "metadata": {}, 27 | "outputs": [ 28 | { 29 | "name": "stdout", 30 | "output_type": "stream", 31 | "text": [ 32 | "Hey\n" 33 | ] 34 | } 35 | ], 36 | "source": [ 37 | "myfunction() # calling a function" 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": 3, 43 | "id": "886a44ce", 44 | "metadata": {}, 45 | "outputs": [ 46 | { 47 | "name": "stdout", 48 | "output_type": "stream", 49 | "text": [ 50 | "1\n", 51 | "2\n", 52 | "1\n", 53 | "2\n" 54 | ] 55 | } 56 | ], 57 | "source": [ 58 | "def paint():\n", 59 | " print(1)\n", 60 | " print(2)\n", 61 | "\n", 62 | "paint()\n", 63 | "paint()" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 4, 69 | "id": "67a3cf6c", 70 | "metadata": {}, 71 | "outputs": [ 72 | { 73 | "ename": "NameError", 74 | "evalue": "name 'hello' is not defined", 75 | "output_type": "error", 76 | "traceback": [ 77 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 78 | "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", 79 | "Input \u001b[1;32mIn [4]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mhello\u001b[49m()\n\u001b[0;32m 3\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mhello\u001b[39m():\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mHello\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", 80 | "\u001b[1;31mNameError\u001b[0m: name 'hello' is not defined" 81 | ] 82 | } 83 | ], 84 | "source": [ 85 | "hello()\n", 86 | "\n", 87 | "def hello():\n", 88 | " print(\"Hello\")" 89 | ] 90 | }, 91 | { 92 | "cell_type": "code", 93 | "execution_count": 6, 94 | "id": "d6dbe303", 95 | "metadata": {}, 96 | "outputs": [ 97 | { 98 | "name": "stdout", 99 | "output_type": "stream", 100 | "text": [ 101 | "2\n" 102 | ] 103 | } 104 | ], 105 | "source": [ 106 | "def indore(a): # a = 2\n", 107 | " print(a)\n", 108 | "\n", 109 | "indore(2)" 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": 7, 115 | "id": "81f5c08c", 116 | "metadata": {}, 117 | "outputs": [ 118 | { 119 | "name": "stdout", 120 | "output_type": "stream", 121 | "text": [ 122 | "A\n" 123 | ] 124 | } 125 | ], 126 | "source": [ 127 | "indore(\"A\")" 128 | ] 129 | }, 130 | { 131 | "cell_type": "code", 132 | "execution_count": 8, 133 | "id": "6ae7d3c9", 134 | "metadata": {}, 135 | "outputs": [ 136 | { 137 | "name": "stdout", 138 | "output_type": "stream", 139 | "text": [ 140 | "right\n" 141 | ] 142 | } 143 | ], 144 | "source": [ 145 | "indore('right')" 146 | ] 147 | }, 148 | { 149 | "cell_type": "code", 150 | "execution_count": 9, 151 | "id": "8f88c2be", 152 | "metadata": {}, 153 | "outputs": [ 154 | { 155 | "name": "stdout", 156 | "output_type": "stream", 157 | "text": [ 158 | "9\n" 159 | ] 160 | } 161 | ], 162 | "source": [ 163 | "def add(x,y):\n", 164 | " print(x+y)\n", 165 | "\n", 166 | "add(5,4)" 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": 10, 172 | "id": "652ebe88", 173 | "metadata": {}, 174 | "outputs": [ 175 | { 176 | "name": "stdout", 177 | "output_type": "stream", 178 | "text": [ 179 | "8\n" 180 | ] 181 | }, 182 | { 183 | "ename": "NameError", 184 | "evalue": "name 'v' is not defined", 185 | "output_type": "error", 186 | "traceback": [ 187 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 188 | "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", 189 | "Input \u001b[1;32mIn [10]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(v)\n\u001b[0;32m 5\u001b[0m add1(\u001b[38;5;241m7\u001b[39m)\n\u001b[1;32m----> 6\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mv\u001b[49m)\n", 190 | "\u001b[1;31mNameError\u001b[0m: name 'v' is not defined" 191 | ] 192 | } 193 | ], 194 | "source": [ 195 | "def add1(v): # v is a local variable\n", 196 | " v += 1\n", 197 | " print(v)\n", 198 | "\n", 199 | "add1(7)\n", 200 | "print(v)" 201 | ] 202 | }, 203 | { 204 | "cell_type": "code", 205 | "execution_count": 11, 206 | "id": "3f341729", 207 | "metadata": {}, 208 | "outputs": [ 209 | { 210 | "name": "stdout", 211 | "output_type": "stream", 212 | "text": [ 213 | "8\n", 214 | "3\n" 215 | ] 216 | } 217 | ], 218 | "source": [ 219 | "v = 3 # v is a global variable\n", 220 | "def add1(v): # v is a local variable\n", 221 | " v += 1\n", 222 | " print(v)\n", 223 | "\n", 224 | "add1(7)\n", 225 | "print(v)" 226 | ] 227 | }, 228 | { 229 | "cell_type": "markdown", 230 | "id": "1d8c04b4", 231 | "metadata": {}, 232 | "source": [ 233 | "# Return statement" 234 | ] 235 | }, 236 | { 237 | "cell_type": "code", 238 | "execution_count": 12, 239 | "id": "d9448b85", 240 | "metadata": {}, 241 | "outputs": [ 242 | { 243 | "name": "stdout", 244 | "output_type": "stream", 245 | "text": [ 246 | "7\n" 247 | ] 248 | } 249 | ], 250 | "source": [ 251 | "def play(x,y):\n", 252 | " if x >= y:\n", 253 | " return x\n", 254 | " else:\n", 255 | " return y\n", 256 | " \n", 257 | "print(play(4,7))\n", 258 | "# 7" 259 | ] 260 | }, 261 | { 262 | "cell_type": "code", 263 | "execution_count": 13, 264 | "id": "60b36c25", 265 | "metadata": {}, 266 | "outputs": [ 267 | { 268 | "name": "stdout", 269 | "output_type": "stream", 270 | "text": [ 271 | "Hi\n" 272 | ] 273 | } 274 | ], 275 | "source": [ 276 | "play(6,3)\n", 277 | "print(\"Hi\")" 278 | ] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "execution_count": 14, 283 | "id": "df5a800d", 284 | "metadata": {}, 285 | "outputs": [ 286 | { 287 | "name": "stdout", 288 | "output_type": "stream", 289 | "text": [ 290 | "6\n" 291 | ] 292 | } 293 | ], 294 | "source": [ 295 | "z = play(6,3)\n", 296 | "\n", 297 | "print(z)" 298 | ] 299 | }, 300 | { 301 | "cell_type": "code", 302 | "execution_count": 15, 303 | "id": "f5949553", 304 | "metadata": {}, 305 | "outputs": [ 306 | { 307 | "name": "stdout", 308 | "output_type": "stream", 309 | "text": [ 310 | "9\n" 311 | ] 312 | } 313 | ], 314 | "source": [ 315 | "def sub(x,y):\n", 316 | " t = x + y\n", 317 | " return t\n", 318 | " print(\"Hi\")\n", 319 | "\n", 320 | "print(sub(4,5))" 321 | ] 322 | }, 323 | { 324 | "cell_type": "code", 325 | "execution_count": 16, 326 | "id": "75b9655c", 327 | "metadata": {}, 328 | "outputs": [ 329 | { 330 | "name": "stdout", 331 | "output_type": "stream", 332 | "text": [ 333 | "1\n", 334 | "2\n" 335 | ] 336 | } 337 | ], 338 | "source": [ 339 | "def pre():\n", 340 | " print(1)\n", 341 | " print(2)\n", 342 | " return\n", 343 | " print(3)\n", 344 | " print(4)\n", 345 | "\n", 346 | "pre()" 347 | ] 348 | }, 349 | { 350 | "cell_type": "code", 351 | "execution_count": 17, 352 | "id": "3a7aca44", 353 | "metadata": {}, 354 | "outputs": [ 355 | { 356 | "name": "stdout", 357 | "output_type": "stream", 358 | "text": [ 359 | "1\n", 360 | "2\n", 361 | "None\n" 362 | ] 363 | } 364 | ], 365 | "source": [ 366 | "print(pre())" 367 | ] 368 | }, 369 | { 370 | "cell_type": "code", 371 | "execution_count": null, 372 | "id": "7b181a5c", 373 | "metadata": {}, 374 | "outputs": [], 375 | "source": [ 376 | "None == NULL" 377 | ] 378 | }, 379 | { 380 | "cell_type": "code", 381 | "execution_count": null, 382 | "id": "e926f675", 383 | "metadata": {}, 384 | "outputs": [], 385 | "source": [ 386 | "None" 387 | ] 388 | }, 389 | { 390 | "cell_type": "code", 391 | "execution_count": 18, 392 | "id": "255483b8", 393 | "metadata": {}, 394 | "outputs": [ 395 | { 396 | "name": "stdout", 397 | "output_type": "stream", 398 | "text": [ 399 | "Hi\n", 400 | "None\n" 401 | ] 402 | } 403 | ], 404 | "source": [ 405 | "def hello():\n", 406 | " print(\"Hi\")\n", 407 | "\n", 408 | "print(hello())" 409 | ] 410 | }, 411 | { 412 | "cell_type": "markdown", 413 | "id": "24d6f6c6", 414 | "metadata": {}, 415 | "source": [ 416 | "# Default Statements" 417 | ] 418 | }, 419 | { 420 | "cell_type": "code", 421 | "execution_count": 19, 422 | "id": "0d69b81d", 423 | "metadata": {}, 424 | "outputs": [ 425 | { 426 | "name": "stdout", 427 | "output_type": "stream", 428 | "text": [ 429 | "Hello\n" 430 | ] 431 | } 432 | ], 433 | "source": [ 434 | "def say(msg, time = 1):\n", 435 | " print(msg * time)\n", 436 | "\n", 437 | "say(\"Hello\")" 438 | ] 439 | }, 440 | { 441 | "cell_type": "code", 442 | "execution_count": 20, 443 | "id": "9c21265c", 444 | "metadata": {}, 445 | "outputs": [ 446 | { 447 | "data": { 448 | "text/plain": [ 449 | "'hihihihihi'" 450 | ] 451 | }, 452 | "execution_count": 20, 453 | "metadata": {}, 454 | "output_type": "execute_result" 455 | } 456 | ], 457 | "source": [ 458 | "\"hi\" * 5" 459 | ] 460 | }, 461 | { 462 | "cell_type": "code", 463 | "execution_count": 21, 464 | "id": "6900b987", 465 | "metadata": {}, 466 | "outputs": [ 467 | { 468 | "name": "stdout", 469 | "output_type": "stream", 470 | "text": [ 471 | "ByeByeByeByeBye\n" 472 | ] 473 | } 474 | ], 475 | "source": [ 476 | "def say(msg, time = 1):\n", 477 | " print(msg * time)\n", 478 | "\n", 479 | "say(\"Bye\", 5)" 480 | ] 481 | }, 482 | { 483 | "cell_type": "code", 484 | "execution_count": 22, 485 | "id": "040c9235", 486 | "metadata": {}, 487 | "outputs": [], 488 | "source": [ 489 | "def said(a, b = 5, c = 10):\n", 490 | " print(a)\n", 491 | " print(b)\n", 492 | " print(c)" 493 | ] 494 | }, 495 | { 496 | "cell_type": "code", 497 | "execution_count": 23, 498 | "id": "de8f4951", 499 | "metadata": {}, 500 | "outputs": [ 501 | { 502 | "name": "stdout", 503 | "output_type": "stream", 504 | "text": [ 505 | "3\n", 506 | "7\n", 507 | "10\n" 508 | ] 509 | } 510 | ], 511 | "source": [ 512 | "said(3,7)" 513 | ] 514 | }, 515 | { 516 | "cell_type": "code", 517 | "execution_count": 24, 518 | "id": "02085cae", 519 | "metadata": {}, 520 | "outputs": [ 521 | { 522 | "name": "stdout", 523 | "output_type": "stream", 524 | "text": [ 525 | "25\n", 526 | "5\n", 527 | "24\n" 528 | ] 529 | } 530 | ], 531 | "source": [ 532 | "said(25, c = 24)" 533 | ] 534 | }, 535 | { 536 | "cell_type": "code", 537 | "execution_count": 25, 538 | "id": "4028a4d1", 539 | "metadata": {}, 540 | "outputs": [ 541 | { 542 | "name": "stdout", 543 | "output_type": "stream", 544 | "text": [ 545 | "100\n", 546 | "5\n", 547 | "50\n" 548 | ] 549 | } 550 | ], 551 | "source": [ 552 | "said(c = 50, a = 100)" 553 | ] 554 | }, 555 | { 556 | "cell_type": "code", 557 | "execution_count": 26, 558 | "id": "146e99d7", 559 | "metadata": { 560 | "scrolled": true 561 | }, 562 | "outputs": [ 563 | { 564 | "ename": "SyntaxError", 565 | "evalue": "positional argument follows keyword argument (1430650584.py, line 1)", 566 | "output_type": "error", 567 | "traceback": [ 568 | "\u001b[1;36m Input \u001b[1;32mIn [26]\u001b[1;36m\u001b[0m\n\u001b[1;33m said(c = 12, 30)\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m positional argument follows keyword argument\n" 569 | ] 570 | } 571 | ], 572 | "source": [ 573 | "said(c = 12, 30)" 574 | ] 575 | }, 576 | { 577 | "cell_type": "code", 578 | "execution_count": 27, 579 | "id": "47ae9ba2", 580 | "metadata": {}, 581 | "outputs": [ 582 | { 583 | "name": "stdout", 584 | "output_type": "stream", 585 | "text": [ 586 | "0\n" 587 | ] 588 | } 589 | ], 590 | "source": [ 591 | "i = 0\n", 592 | "def change(i):\n", 593 | " i += 1\n", 594 | " return 1\n", 595 | "\n", 596 | "change(1)\n", 597 | "print(i)" 598 | ] 599 | }, 600 | { 601 | "cell_type": "markdown", 602 | "id": "91908e9d", 603 | "metadata": {}, 604 | "source": [ 605 | "# Reference Function" 606 | ] 607 | }, 608 | { 609 | "cell_type": "code", 610 | "execution_count": 28, 611 | "id": "1b93869f", 612 | "metadata": {}, 613 | "outputs": [ 614 | { 615 | "name": "stdout", 616 | "output_type": "stream", 617 | "text": [ 618 | "28\n" 619 | ] 620 | } 621 | ], 622 | "source": [ 623 | "def multiply(x,y):\n", 624 | " return x * y\n", 625 | "\n", 626 | "\n", 627 | "operation = multiply\n", 628 | "\n", 629 | "\n", 630 | "print(operation(4,7))\n", 631 | "# multiply(4,7)" 632 | ] 633 | }, 634 | { 635 | "cell_type": "code", 636 | "execution_count": 31, 637 | "id": "cdbd1b8f", 638 | "metadata": {}, 639 | "outputs": [ 640 | { 641 | "name": "stdout", 642 | "output_type": "stream", 643 | "text": [ 644 | "10\n", 645 | "2074337897040\n", 646 | "10\n", 647 | "2074337897040\n", 648 | "2074337897104\n" 649 | ] 650 | } 651 | ], 652 | "source": [ 653 | "a = 10\n", 654 | "b = a\n", 655 | "print(a)\n", 656 | "print(id(a))\n", 657 | "print(b)\n", 658 | "print(id(b))\n", 659 | "b = 12\n", 660 | "print(id(b))" 661 | ] 662 | }, 663 | { 664 | "cell_type": "code", 665 | "execution_count": 32, 666 | "id": "d45c303e", 667 | "metadata": {}, 668 | "outputs": [ 669 | { 670 | "name": "stdout", 671 | "output_type": "stream", 672 | "text": [ 673 | "\n" 674 | ] 675 | } 676 | ], 677 | "source": [ 678 | "print(type(multiply))" 679 | ] 680 | }, 681 | { 682 | "cell_type": "code", 683 | "execution_count": 33, 684 | "id": "777316a1", 685 | "metadata": {}, 686 | "outputs": [ 687 | { 688 | "name": "stdout", 689 | "output_type": "stream", 690 | "text": [ 691 | "India!\n" 692 | ] 693 | } 694 | ], 695 | "source": [ 696 | "def indore(a):\n", 697 | " return a + \"!\"\n", 698 | "\n", 699 | "m = indore\n", 700 | "\n", 701 | "z = m('India')\n", 702 | "# indore('India')\n", 703 | "\n", 704 | "print(z)" 705 | ] 706 | }, 707 | { 708 | "cell_type": "markdown", 709 | "id": "6ed66946", 710 | "metadata": {}, 711 | "source": [ 712 | "# Function as an Argument" 713 | ] 714 | }, 715 | { 716 | "cell_type": "code", 717 | "execution_count": 34, 718 | "id": "ab2bb98b", 719 | "metadata": {}, 720 | "outputs": [ 721 | { 722 | "name": "stdout", 723 | "output_type": "stream", 724 | "text": [ 725 | "30\n" 726 | ] 727 | } 728 | ], 729 | "source": [ 730 | "def sub(x,y):\n", 731 | " return x + y\n", 732 | "\n", 733 | "def do(red, x, y): # red = sub\n", 734 | " return red(red(x,y), red(x,y))\n", 735 | " # sub(sub(5,10), sub(5,10))\n", 736 | " # sub( 15 , 15 )\n", 737 | " #return 30\n", 738 | "a = 5\n", 739 | "b = 10\n", 740 | "\n", 741 | "print(do(sub, a, b))\n", 742 | "# 30" 743 | ] 744 | }, 745 | { 746 | "cell_type": "code", 747 | "execution_count": 35, 748 | "id": "3b4e3747", 749 | "metadata": {}, 750 | "outputs": [ 751 | { 752 | "name": "stdout", 753 | "output_type": "stream", 754 | "text": [ 755 | "81\n" 756 | ] 757 | } 758 | ], 759 | "source": [ 760 | "def square(x):\n", 761 | " return x * x\n", 762 | "\n", 763 | "def test(blue, x):\n", 764 | " print(blue(x))\n", 765 | " # square(9)\n", 766 | "\n", 767 | "test(square, 9)" 768 | ] 769 | }, 770 | { 771 | "cell_type": "code", 772 | "execution_count": 36, 773 | "id": "d8ce2e0b", 774 | "metadata": {}, 775 | "outputs": [ 776 | { 777 | "name": "stdout", 778 | "output_type": "stream", 779 | "text": [ 780 | "[1]\n" 781 | ] 782 | } 783 | ], 784 | "source": [ 785 | "def go(t): # t = q = [0]\n", 786 | " t[0] = 1 # t[0] = 1, t = [1] = q\n", 787 | " \n", 788 | "q = [0]\n", 789 | "# 0\n", 790 | "go(q)\n", 791 | "print(q)" 792 | ] 793 | }, 794 | { 795 | "cell_type": "code", 796 | "execution_count": 37, 797 | "id": "e0d4fe34", 798 | "metadata": {}, 799 | "outputs": [ 800 | { 801 | "name": "stdout", 802 | "output_type": "stream", 803 | "text": [ 804 | "3\n", 805 | "4\n" 806 | ] 807 | } 808 | ], 809 | "source": [ 810 | "def green(red, a):\n", 811 | " print(red(a))\n", 812 | "\n", 813 | "green(max,[1,2,3])\n", 814 | "green(min,[4,5,6])" 815 | ] 816 | }, 817 | { 818 | "cell_type": "code", 819 | "execution_count": 38, 820 | "id": "82edc6cc", 821 | "metadata": {}, 822 | "outputs": [ 823 | { 824 | "name": "stdout", 825 | "output_type": "stream", 826 | "text": [ 827 | "0\n" 828 | ] 829 | } 830 | ], 831 | "source": [ 832 | "def printn(x):\n", 833 | " for i in range(x):\n", 834 | " print(i)\n", 835 | " return\n", 836 | "\n", 837 | "printn(10)" 838 | ] 839 | }, 840 | { 841 | "cell_type": "markdown", 842 | "id": "361a1a86", 843 | "metadata": {}, 844 | "source": [ 845 | "# Lambda function\n", 846 | "\n", 847 | "anonymous function" 848 | ] 849 | }, 850 | { 851 | "cell_type": "code", 852 | "execution_count": 39, 853 | "id": "37f10c3d", 854 | "metadata": {}, 855 | "outputs": [ 856 | { 857 | "name": "stdout", 858 | "output_type": "stream", 859 | "text": [ 860 | "343\n" 861 | ] 862 | } 863 | ], 864 | "source": [ 865 | "def cube(y):\n", 866 | " return y * y * y\n", 867 | "\n", 868 | "\n", 869 | "# lambda argument : statement/expression\n", 870 | "g = lambda x: x * x * x\n", 871 | "\n", 872 | "print(g(7))" 873 | ] 874 | }, 875 | { 876 | "cell_type": "code", 877 | "execution_count": 40, 878 | "id": "a30b53ee", 879 | "metadata": {}, 880 | "outputs": [ 881 | { 882 | "data": { 883 | "text/plain": [ 884 | "343" 885 | ] 886 | }, 887 | "execution_count": 40, 888 | "metadata": {}, 889 | "output_type": "execute_result" 890 | } 891 | ], 892 | "source": [ 893 | "cube(7)" 894 | ] 895 | }, 896 | { 897 | "cell_type": "code", 898 | "execution_count": 41, 899 | "id": "4d299e4b", 900 | "metadata": {}, 901 | "outputs": [ 902 | { 903 | "name": "stdout", 904 | "output_type": "stream", 905 | "text": [ 906 | "7\n", 907 | "None\n" 908 | ] 909 | } 910 | ], 911 | "source": [ 912 | "g = lambda x: print(x)\n", 913 | "\n", 914 | "print(g(7))" 915 | ] 916 | }, 917 | { 918 | "cell_type": "markdown", 919 | "id": "3d73b238", 920 | "metadata": {}, 921 | "source": [ 922 | "# Filter function" 923 | ] 924 | }, 925 | { 926 | "cell_type": "code", 927 | "execution_count": 42, 928 | "id": "755bc6e4", 929 | "metadata": {}, 930 | "outputs": [ 931 | { 932 | "name": "stdout", 933 | "output_type": "stream", 934 | "text": [ 935 | "[22, 44]\n" 936 | ] 937 | } 938 | ], 939 | "source": [ 940 | "n = [11,22,33,44,55]\n", 941 | "\n", 942 | "r = list(filter(lambda x: x%2 == 0 , n))\n", 943 | "\n", 944 | "print(r)" 945 | ] 946 | }, 947 | { 948 | "cell_type": "code", 949 | "execution_count": 43, 950 | "id": "547646b9", 951 | "metadata": {}, 952 | "outputs": [ 953 | { 954 | "name": "stdout", 955 | "output_type": "stream", 956 | "text": [ 957 | "[11, 33, 55]\n" 958 | ] 959 | } 960 | ], 961 | "source": [ 962 | "n = [11,22,33,44,55]\n", 963 | "\n", 964 | "r = list(filter(lambda x: x%2 == 1 , n))\n", 965 | "\n", 966 | "print(r)" 967 | ] 968 | }, 969 | { 970 | "cell_type": "markdown", 971 | "id": "6024f003", 972 | "metadata": {}, 973 | "source": [ 974 | "# map function" 975 | ] 976 | }, 977 | { 978 | "cell_type": "code", 979 | "execution_count": 44, 980 | "id": "fd40e98e", 981 | "metadata": {}, 982 | "outputs": [ 983 | { 984 | "name": "stdout", 985 | "output_type": "stream", 986 | "text": [ 987 | "[6, 7, 8, 9, 10]\n" 988 | ] 989 | } 990 | ], 991 | "source": [ 992 | "n = [1,2,3,4,5]\n", 993 | "\n", 994 | "r = list(map(lambda y: y + 5 , n))\n", 995 | "\n", 996 | "print(r)" 997 | ] 998 | }, 999 | { 1000 | "cell_type": "code", 1001 | "execution_count": 45, 1002 | "id": "624d82ea", 1003 | "metadata": {}, 1004 | "outputs": [ 1005 | { 1006 | "data": { 1007 | "text/plain": [ 1008 | "'INDORE'" 1009 | ] 1010 | }, 1011 | "execution_count": 45, 1012 | "metadata": {}, 1013 | "output_type": "execute_result" 1014 | } 1015 | ], 1016 | "source": [ 1017 | "n = [\"indore\", 'goa', 'vizag']\n", 1018 | "\n", 1019 | "n[0].upper()" 1020 | ] 1021 | }, 1022 | { 1023 | "cell_type": "code", 1024 | "execution_count": 50, 1025 | "id": "25643a01", 1026 | "metadata": { 1027 | "scrolled": false 1028 | }, 1029 | "outputs": [], 1030 | "source": [ 1031 | "# help(str)" 1032 | ] 1033 | }, 1034 | { 1035 | "cell_type": "code", 1036 | "execution_count": 51, 1037 | "id": "02bda1b6", 1038 | "metadata": {}, 1039 | "outputs": [ 1040 | { 1041 | "data": { 1042 | "text/plain": [ 1043 | "'INDIA'" 1044 | ] 1045 | }, 1046 | "execution_count": 51, 1047 | "metadata": {}, 1048 | "output_type": "execute_result" 1049 | } 1050 | ], 1051 | "source": [ 1052 | "\"india\".upper()" 1053 | ] 1054 | }, 1055 | { 1056 | "cell_type": "code", 1057 | "execution_count": 48, 1058 | "id": "6773c993", 1059 | "metadata": {}, 1060 | "outputs": [ 1061 | { 1062 | "name": "stdout", 1063 | "output_type": "stream", 1064 | "text": [ 1065 | "['INDORE', 'GOA', 'VIZAG']\n" 1066 | ] 1067 | } 1068 | ], 1069 | "source": [ 1070 | "def up(a):\n", 1071 | " return a.upper()\n", 1072 | "\n", 1073 | "n = [\"indore\", 'goa', 'vizag']\n", 1074 | "\n", 1075 | "r = list(map(up, n))\n", 1076 | "\n", 1077 | "print(r)" 1078 | ] 1079 | }, 1080 | { 1081 | "cell_type": "code", 1082 | "execution_count": 52, 1083 | "id": "ff001f1e", 1084 | "metadata": {}, 1085 | "outputs": [ 1086 | { 1087 | "name": "stdout", 1088 | "output_type": "stream", 1089 | "text": [ 1090 | "Help on class map in module builtins:\n", 1091 | "\n", 1092 | "class map(object)\n", 1093 | " | map(func, *iterables) --> map object\n", 1094 | " | \n", 1095 | " | Make an iterator that computes the function using arguments from\n", 1096 | " | each of the iterables. Stops when the shortest iterable is exhausted.\n", 1097 | " | \n", 1098 | " | Methods defined here:\n", 1099 | " | \n", 1100 | " | __getattribute__(self, name, /)\n", 1101 | " | Return getattr(self, name).\n", 1102 | " | \n", 1103 | " | __iter__(self, /)\n", 1104 | " | Implement iter(self).\n", 1105 | " | \n", 1106 | " | __next__(self, /)\n", 1107 | " | Implement next(self).\n", 1108 | " | \n", 1109 | " | __reduce__(...)\n", 1110 | " | Return state information for pickling.\n", 1111 | " | \n", 1112 | " | ----------------------------------------------------------------------\n", 1113 | " | Static methods defined here:\n", 1114 | " | \n", 1115 | " | __new__(*args, **kwargs) from builtins.type\n", 1116 | " | Create and return a new object. See help(type) for accurate signature.\n", 1117 | "\n" 1118 | ] 1119 | } 1120 | ], 1121 | "source": [ 1122 | "help(map)" 1123 | ] 1124 | }, 1125 | { 1126 | "cell_type": "markdown", 1127 | "id": "f07c7946", 1128 | "metadata": {}, 1129 | "source": [ 1130 | "# Closuers" 1131 | ] 1132 | }, 1133 | { 1134 | "cell_type": "code", 1135 | "execution_count": 53, 1136 | "id": "98a47a83", 1137 | "metadata": {}, 1138 | "outputs": [], 1139 | "source": [ 1140 | "def add_ten():\n", 1141 | " ten = 10\n", 1142 | " \n", 1143 | " def add(n):\n", 1144 | " return n + ten\n", 1145 | " \n", 1146 | " return add" 1147 | ] 1148 | }, 1149 | { 1150 | "cell_type": "code", 1151 | "execution_count": 54, 1152 | "id": "5f78a373", 1153 | "metadata": {}, 1154 | "outputs": [ 1155 | { 1156 | "name": "stdout", 1157 | "output_type": "stream", 1158 | "text": [ 1159 | "15\n" 1160 | ] 1161 | } 1162 | ], 1163 | "source": [ 1164 | "clouser_result = add_ten()\n", 1165 | "\n", 1166 | "print(clouser_result(5))\n", 1167 | "# add(5)" 1168 | ] 1169 | }, 1170 | { 1171 | "cell_type": "code", 1172 | "execution_count": 55, 1173 | "id": "565827f6", 1174 | "metadata": {}, 1175 | "outputs": [ 1176 | { 1177 | "name": "stdout", 1178 | "output_type": "stream", 1179 | "text": [ 1180 | "20\n" 1181 | ] 1182 | } 1183 | ], 1184 | "source": [ 1185 | "print(clouser_result(10))" 1186 | ] 1187 | }, 1188 | { 1189 | "cell_type": "markdown", 1190 | "id": "b4f3a26c", 1191 | "metadata": {}, 1192 | "source": [ 1193 | "# Decorators" 1194 | ] 1195 | }, 1196 | { 1197 | "cell_type": "code", 1198 | "execution_count": 57, 1199 | "id": "7f12459c", 1200 | "metadata": { 1201 | "scrolled": false 1202 | }, 1203 | "outputs": [], 1204 | "source": [ 1205 | "# help(str)" 1206 | ] 1207 | }, 1208 | { 1209 | "cell_type": "code", 1210 | "execution_count": 58, 1211 | "id": "3c579a09", 1212 | "metadata": {}, 1213 | "outputs": [ 1214 | { 1215 | "name": "stdout", 1216 | "output_type": "stream", 1217 | "text": [ 1218 | "HELLO HOW ARE YOU? WELCOME\n" 1219 | ] 1220 | } 1221 | ], 1222 | "source": [ 1223 | "def greeting():\n", 1224 | " return \"Hello How are you? Welcome\"\n", 1225 | "\n", 1226 | "def uppercase_decorator(function):\n", 1227 | " def wrapper():\n", 1228 | " f = function()\n", 1229 | " u = f.upper()\n", 1230 | " return u\n", 1231 | " return wrapper\n", 1232 | "\n", 1233 | "g = uppercase_decorator(greeting)\n", 1234 | "print(g())" 1235 | ] 1236 | }, 1237 | { 1238 | "cell_type": "code", 1239 | "execution_count": 59, 1240 | "id": "a5b98d6f", 1241 | "metadata": {}, 1242 | "outputs": [ 1243 | { 1244 | "name": "stdout", 1245 | "output_type": "stream", 1246 | "text": [ 1247 | "WELCOME HERE\n" 1248 | ] 1249 | } 1250 | ], 1251 | "source": [ 1252 | "def uppercase_decorator(function):\n", 1253 | " def wrapper():\n", 1254 | " f = function()\n", 1255 | " u = f.upper()\n", 1256 | " return u\n", 1257 | " return wrapper\n", 1258 | "\n", 1259 | "@uppercase_decorator\n", 1260 | "def greeting():\n", 1261 | " return 'Welcome here'\n", 1262 | "\n", 1263 | "\n", 1264 | "print(greeting())" 1265 | ] 1266 | }, 1267 | { 1268 | "cell_type": "code", 1269 | "execution_count": null, 1270 | "id": "97c568f1", 1271 | "metadata": {}, 1272 | "outputs": [], 1273 | "source": [] 1274 | } 1275 | ], 1276 | "metadata": { 1277 | "kernelspec": { 1278 | "display_name": "Python 3 (ipykernel)", 1279 | "language": "python", 1280 | "name": "python3" 1281 | }, 1282 | "language_info": { 1283 | "codemirror_mode": { 1284 | "name": "ipython", 1285 | "version": 3 1286 | }, 1287 | "file_extension": ".py", 1288 | "mimetype": "text/x-python", 1289 | "name": "python", 1290 | "nbconvert_exporter": "python", 1291 | "pygments_lexer": "ipython3", 1292 | "version": "3.9.12" 1293 | } 1294 | }, 1295 | "nbformat": 4, 1296 | "nbformat_minor": 5 1297 | } 1298 | -------------------------------------------------------------------------------- /04_Functions, Higher Order Functions/4_Functions.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "d9d3b384", 6 | "metadata": {}, 7 | "source": [ 8 | "# Functions" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "243d1342", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "def myfunction(): # definition of a function\n", 19 | " print(\"Hey\")" 20 | ] 21 | }, 22 | { 23 | "cell_type": "code", 24 | "execution_count": 2, 25 | "id": "e16c3fe1", 26 | "metadata": {}, 27 | "outputs": [ 28 | { 29 | "name": "stdout", 30 | "output_type": "stream", 31 | "text": [ 32 | "Hey\n" 33 | ] 34 | } 35 | ], 36 | "source": [ 37 | "myfunction() # calling a function" 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": 3, 43 | "id": "886a44ce", 44 | "metadata": {}, 45 | "outputs": [ 46 | { 47 | "name": "stdout", 48 | "output_type": "stream", 49 | "text": [ 50 | "1\n", 51 | "2\n", 52 | "1\n", 53 | "2\n" 54 | ] 55 | } 56 | ], 57 | "source": [ 58 | "def paint():\n", 59 | " print(1)\n", 60 | " print(2)\n", 61 | "\n", 62 | "paint()\n", 63 | "paint()" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 4, 69 | "id": "67a3cf6c", 70 | "metadata": {}, 71 | "outputs": [ 72 | { 73 | "ename": "NameError", 74 | "evalue": "name 'hello' is not defined", 75 | "output_type": "error", 76 | "traceback": [ 77 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 78 | "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", 79 | "Input \u001b[1;32mIn [4]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mhello\u001b[49m()\n\u001b[0;32m 3\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mhello\u001b[39m():\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mHello\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", 80 | "\u001b[1;31mNameError\u001b[0m: name 'hello' is not defined" 81 | ] 82 | } 83 | ], 84 | "source": [ 85 | "hello()\n", 86 | "\n", 87 | "def hello():\n", 88 | " print(\"Hello\")" 89 | ] 90 | }, 91 | { 92 | "cell_type": "code", 93 | "execution_count": 6, 94 | "id": "d6dbe303", 95 | "metadata": {}, 96 | "outputs": [ 97 | { 98 | "name": "stdout", 99 | "output_type": "stream", 100 | "text": [ 101 | "2\n" 102 | ] 103 | } 104 | ], 105 | "source": [ 106 | "def indore(a): # a = 2\n", 107 | " print(a)\n", 108 | "\n", 109 | "indore(2)" 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": 7, 115 | "id": "81f5c08c", 116 | "metadata": {}, 117 | "outputs": [ 118 | { 119 | "name": "stdout", 120 | "output_type": "stream", 121 | "text": [ 122 | "A\n" 123 | ] 124 | } 125 | ], 126 | "source": [ 127 | "indore(\"A\")" 128 | ] 129 | }, 130 | { 131 | "cell_type": "code", 132 | "execution_count": 8, 133 | "id": "6ae7d3c9", 134 | "metadata": {}, 135 | "outputs": [ 136 | { 137 | "name": "stdout", 138 | "output_type": "stream", 139 | "text": [ 140 | "right\n" 141 | ] 142 | } 143 | ], 144 | "source": [ 145 | "indore('right')" 146 | ] 147 | }, 148 | { 149 | "cell_type": "code", 150 | "execution_count": 9, 151 | "id": "8f88c2be", 152 | "metadata": {}, 153 | "outputs": [ 154 | { 155 | "name": "stdout", 156 | "output_type": "stream", 157 | "text": [ 158 | "9\n" 159 | ] 160 | } 161 | ], 162 | "source": [ 163 | "def add(x,y):\n", 164 | " print(x+y)\n", 165 | "\n", 166 | "add(5,4)" 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": 10, 172 | "id": "652ebe88", 173 | "metadata": {}, 174 | "outputs": [ 175 | { 176 | "name": "stdout", 177 | "output_type": "stream", 178 | "text": [ 179 | "8\n" 180 | ] 181 | }, 182 | { 183 | "ename": "NameError", 184 | "evalue": "name 'v' is not defined", 185 | "output_type": "error", 186 | "traceback": [ 187 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 188 | "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", 189 | "Input \u001b[1;32mIn [10]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(v)\n\u001b[0;32m 5\u001b[0m add1(\u001b[38;5;241m7\u001b[39m)\n\u001b[1;32m----> 6\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mv\u001b[49m)\n", 190 | "\u001b[1;31mNameError\u001b[0m: name 'v' is not defined" 191 | ] 192 | } 193 | ], 194 | "source": [ 195 | "def add1(v): # v is a local variable\n", 196 | " v += 1\n", 197 | " print(v)\n", 198 | "\n", 199 | "add1(7)\n", 200 | "print(v)" 201 | ] 202 | }, 203 | { 204 | "cell_type": "code", 205 | "execution_count": 11, 206 | "id": "3f341729", 207 | "metadata": {}, 208 | "outputs": [ 209 | { 210 | "name": "stdout", 211 | "output_type": "stream", 212 | "text": [ 213 | "8\n", 214 | "3\n" 215 | ] 216 | } 217 | ], 218 | "source": [ 219 | "v = 3 # v is a global variable\n", 220 | "def add1(v): # v is a local variable\n", 221 | " v += 1\n", 222 | " print(v)\n", 223 | "\n", 224 | "add1(7)\n", 225 | "print(v)" 226 | ] 227 | }, 228 | { 229 | "cell_type": "markdown", 230 | "id": "1d8c04b4", 231 | "metadata": {}, 232 | "source": [ 233 | "# Return statement" 234 | ] 235 | }, 236 | { 237 | "cell_type": "code", 238 | "execution_count": 12, 239 | "id": "d9448b85", 240 | "metadata": {}, 241 | "outputs": [ 242 | { 243 | "name": "stdout", 244 | "output_type": "stream", 245 | "text": [ 246 | "7\n" 247 | ] 248 | } 249 | ], 250 | "source": [ 251 | "def play(x,y):\n", 252 | " if x >= y:\n", 253 | " return x\n", 254 | " else:\n", 255 | " return y\n", 256 | " \n", 257 | "print(play(4,7))\n", 258 | "# 7" 259 | ] 260 | }, 261 | { 262 | "cell_type": "code", 263 | "execution_count": 13, 264 | "id": "60b36c25", 265 | "metadata": {}, 266 | "outputs": [ 267 | { 268 | "name": "stdout", 269 | "output_type": "stream", 270 | "text": [ 271 | "Hi\n" 272 | ] 273 | } 274 | ], 275 | "source": [ 276 | "play(6,3)\n", 277 | "print(\"Hi\")" 278 | ] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "execution_count": 14, 283 | "id": "df5a800d", 284 | "metadata": {}, 285 | "outputs": [ 286 | { 287 | "name": "stdout", 288 | "output_type": "stream", 289 | "text": [ 290 | "6\n" 291 | ] 292 | } 293 | ], 294 | "source": [ 295 | "z = play(6,3)\n", 296 | "\n", 297 | "print(z)" 298 | ] 299 | }, 300 | { 301 | "cell_type": "code", 302 | "execution_count": 15, 303 | "id": "f5949553", 304 | "metadata": {}, 305 | "outputs": [ 306 | { 307 | "name": "stdout", 308 | "output_type": "stream", 309 | "text": [ 310 | "9\n" 311 | ] 312 | } 313 | ], 314 | "source": [ 315 | "def sub(x,y):\n", 316 | " t = x + y\n", 317 | " return t\n", 318 | " print(\"Hi\")\n", 319 | "\n", 320 | "print(sub(4,5))" 321 | ] 322 | }, 323 | { 324 | "cell_type": "code", 325 | "execution_count": 16, 326 | "id": "75b9655c", 327 | "metadata": {}, 328 | "outputs": [ 329 | { 330 | "name": "stdout", 331 | "output_type": "stream", 332 | "text": [ 333 | "1\n", 334 | "2\n" 335 | ] 336 | } 337 | ], 338 | "source": [ 339 | "def pre():\n", 340 | " print(1)\n", 341 | " print(2)\n", 342 | " return\n", 343 | " print(3)\n", 344 | " print(4)\n", 345 | "\n", 346 | "pre()" 347 | ] 348 | }, 349 | { 350 | "cell_type": "code", 351 | "execution_count": 17, 352 | "id": "3a7aca44", 353 | "metadata": {}, 354 | "outputs": [ 355 | { 356 | "name": "stdout", 357 | "output_type": "stream", 358 | "text": [ 359 | "1\n", 360 | "2\n", 361 | "None\n" 362 | ] 363 | } 364 | ], 365 | "source": [ 366 | "print(pre())" 367 | ] 368 | }, 369 | { 370 | "cell_type": "code", 371 | "execution_count": null, 372 | "id": "7b181a5c", 373 | "metadata": {}, 374 | "outputs": [], 375 | "source": [ 376 | "None == NULL" 377 | ] 378 | }, 379 | { 380 | "cell_type": "code", 381 | "execution_count": null, 382 | "id": "e926f675", 383 | "metadata": {}, 384 | "outputs": [], 385 | "source": [ 386 | "None" 387 | ] 388 | }, 389 | { 390 | "cell_type": "code", 391 | "execution_count": 18, 392 | "id": "255483b8", 393 | "metadata": {}, 394 | "outputs": [ 395 | { 396 | "name": "stdout", 397 | "output_type": "stream", 398 | "text": [ 399 | "Hi\n", 400 | "None\n" 401 | ] 402 | } 403 | ], 404 | "source": [ 405 | "def hello():\n", 406 | " print(\"Hi\")\n", 407 | "\n", 408 | "print(hello())" 409 | ] 410 | }, 411 | { 412 | "cell_type": "markdown", 413 | "id": "24d6f6c6", 414 | "metadata": {}, 415 | "source": [ 416 | "# Default Statements" 417 | ] 418 | }, 419 | { 420 | "cell_type": "code", 421 | "execution_count": 19, 422 | "id": "0d69b81d", 423 | "metadata": {}, 424 | "outputs": [ 425 | { 426 | "name": "stdout", 427 | "output_type": "stream", 428 | "text": [ 429 | "Hello\n" 430 | ] 431 | } 432 | ], 433 | "source": [ 434 | "def say(msg, time = 1):\n", 435 | " print(msg * time)\n", 436 | "\n", 437 | "say(\"Hello\")" 438 | ] 439 | }, 440 | { 441 | "cell_type": "code", 442 | "execution_count": 20, 443 | "id": "9c21265c", 444 | "metadata": {}, 445 | "outputs": [ 446 | { 447 | "data": { 448 | "text/plain": [ 449 | "'hihihihihi'" 450 | ] 451 | }, 452 | "execution_count": 20, 453 | "metadata": {}, 454 | "output_type": "execute_result" 455 | } 456 | ], 457 | "source": [ 458 | "\"hi\" * 5" 459 | ] 460 | }, 461 | { 462 | "cell_type": "code", 463 | "execution_count": 21, 464 | "id": "6900b987", 465 | "metadata": {}, 466 | "outputs": [ 467 | { 468 | "name": "stdout", 469 | "output_type": "stream", 470 | "text": [ 471 | "ByeByeByeByeBye\n" 472 | ] 473 | } 474 | ], 475 | "source": [ 476 | "def say(msg, time = 1):\n", 477 | " print(msg * time)\n", 478 | "\n", 479 | "say(\"Bye\", 5)" 480 | ] 481 | }, 482 | { 483 | "cell_type": "code", 484 | "execution_count": 22, 485 | "id": "040c9235", 486 | "metadata": {}, 487 | "outputs": [], 488 | "source": [ 489 | "def said(a, b = 5, c = 10):\n", 490 | " print(a)\n", 491 | " print(b)\n", 492 | " print(c)" 493 | ] 494 | }, 495 | { 496 | "cell_type": "code", 497 | "execution_count": 23, 498 | "id": "de8f4951", 499 | "metadata": {}, 500 | "outputs": [ 501 | { 502 | "name": "stdout", 503 | "output_type": "stream", 504 | "text": [ 505 | "3\n", 506 | "7\n", 507 | "10\n" 508 | ] 509 | } 510 | ], 511 | "source": [ 512 | "said(3,7)" 513 | ] 514 | }, 515 | { 516 | "cell_type": "code", 517 | "execution_count": 24, 518 | "id": "02085cae", 519 | "metadata": {}, 520 | "outputs": [ 521 | { 522 | "name": "stdout", 523 | "output_type": "stream", 524 | "text": [ 525 | "25\n", 526 | "5\n", 527 | "24\n" 528 | ] 529 | } 530 | ], 531 | "source": [ 532 | "said(25, c = 24)" 533 | ] 534 | }, 535 | { 536 | "cell_type": "code", 537 | "execution_count": 25, 538 | "id": "4028a4d1", 539 | "metadata": {}, 540 | "outputs": [ 541 | { 542 | "name": "stdout", 543 | "output_type": "stream", 544 | "text": [ 545 | "100\n", 546 | "5\n", 547 | "50\n" 548 | ] 549 | } 550 | ], 551 | "source": [ 552 | "said(c = 50, a = 100)" 553 | ] 554 | }, 555 | { 556 | "cell_type": "code", 557 | "execution_count": 26, 558 | "id": "146e99d7", 559 | "metadata": { 560 | "scrolled": true 561 | }, 562 | "outputs": [ 563 | { 564 | "ename": "SyntaxError", 565 | "evalue": "positional argument follows keyword argument (1430650584.py, line 1)", 566 | "output_type": "error", 567 | "traceback": [ 568 | "\u001b[1;36m Input \u001b[1;32mIn [26]\u001b[1;36m\u001b[0m\n\u001b[1;33m said(c = 12, 30)\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m positional argument follows keyword argument\n" 569 | ] 570 | } 571 | ], 572 | "source": [ 573 | "said(c = 12, 30)" 574 | ] 575 | }, 576 | { 577 | "cell_type": "code", 578 | "execution_count": 27, 579 | "id": "47ae9ba2", 580 | "metadata": {}, 581 | "outputs": [ 582 | { 583 | "name": "stdout", 584 | "output_type": "stream", 585 | "text": [ 586 | "0\n" 587 | ] 588 | } 589 | ], 590 | "source": [ 591 | "i = 0\n", 592 | "def change(i):\n", 593 | " i += 1\n", 594 | " return 1\n", 595 | "\n", 596 | "change(1)\n", 597 | "print(i)" 598 | ] 599 | }, 600 | { 601 | "cell_type": "markdown", 602 | "id": "91908e9d", 603 | "metadata": {}, 604 | "source": [ 605 | "# Reference Function" 606 | ] 607 | }, 608 | { 609 | "cell_type": "code", 610 | "execution_count": 28, 611 | "id": "1b93869f", 612 | "metadata": {}, 613 | "outputs": [ 614 | { 615 | "name": "stdout", 616 | "output_type": "stream", 617 | "text": [ 618 | "28\n" 619 | ] 620 | } 621 | ], 622 | "source": [ 623 | "def multiply(x,y):\n", 624 | " return x * y\n", 625 | "\n", 626 | "\n", 627 | "operation = multiply\n", 628 | "\n", 629 | "\n", 630 | "print(operation(4,7))\n", 631 | "# multiply(4,7)" 632 | ] 633 | }, 634 | { 635 | "cell_type": "code", 636 | "execution_count": 31, 637 | "id": "cdbd1b8f", 638 | "metadata": {}, 639 | "outputs": [ 640 | { 641 | "name": "stdout", 642 | "output_type": "stream", 643 | "text": [ 644 | "10\n", 645 | "2074337897040\n", 646 | "10\n", 647 | "2074337897040\n", 648 | "2074337897104\n" 649 | ] 650 | } 651 | ], 652 | "source": [ 653 | "a = 10\n", 654 | "b = a\n", 655 | "print(a)\n", 656 | "print(id(a))\n", 657 | "print(b)\n", 658 | "print(id(b))\n", 659 | "b = 12\n", 660 | "print(id(b))" 661 | ] 662 | }, 663 | { 664 | "cell_type": "code", 665 | "execution_count": 32, 666 | "id": "d45c303e", 667 | "metadata": {}, 668 | "outputs": [ 669 | { 670 | "name": "stdout", 671 | "output_type": "stream", 672 | "text": [ 673 | "\n" 674 | ] 675 | } 676 | ], 677 | "source": [ 678 | "print(type(multiply))" 679 | ] 680 | }, 681 | { 682 | "cell_type": "code", 683 | "execution_count": 33, 684 | "id": "777316a1", 685 | "metadata": {}, 686 | "outputs": [ 687 | { 688 | "name": "stdout", 689 | "output_type": "stream", 690 | "text": [ 691 | "India!\n" 692 | ] 693 | } 694 | ], 695 | "source": [ 696 | "def indore(a):\n", 697 | " return a + \"!\"\n", 698 | "\n", 699 | "m = indore\n", 700 | "\n", 701 | "z = m('India')\n", 702 | "# indore('India')\n", 703 | "\n", 704 | "print(z)" 705 | ] 706 | }, 707 | { 708 | "cell_type": "markdown", 709 | "id": "6ed66946", 710 | "metadata": {}, 711 | "source": [ 712 | "# Function as an Argument" 713 | ] 714 | }, 715 | { 716 | "cell_type": "code", 717 | "execution_count": 34, 718 | "id": "ab2bb98b", 719 | "metadata": {}, 720 | "outputs": [ 721 | { 722 | "name": "stdout", 723 | "output_type": "stream", 724 | "text": [ 725 | "30\n" 726 | ] 727 | } 728 | ], 729 | "source": [ 730 | "def sub(x,y):\n", 731 | " return x + y\n", 732 | "\n", 733 | "def do(red, x, y): # red = sub\n", 734 | " return red(red(x,y), red(x,y))\n", 735 | " # sub(sub(5,10), sub(5,10))\n", 736 | " # sub( 15 , 15 )\n", 737 | " #return 30\n", 738 | "a = 5\n", 739 | "b = 10\n", 740 | "\n", 741 | "print(do(sub, a, b))\n", 742 | "# 30" 743 | ] 744 | }, 745 | { 746 | "cell_type": "code", 747 | "execution_count": 35, 748 | "id": "3b4e3747", 749 | "metadata": {}, 750 | "outputs": [ 751 | { 752 | "name": "stdout", 753 | "output_type": "stream", 754 | "text": [ 755 | "81\n" 756 | ] 757 | } 758 | ], 759 | "source": [ 760 | "def square(x):\n", 761 | " return x * x\n", 762 | "\n", 763 | "def test(blue, x):\n", 764 | " print(blue(x))\n", 765 | " # square(9)\n", 766 | "\n", 767 | "test(square, 9)" 768 | ] 769 | }, 770 | { 771 | "cell_type": "code", 772 | "execution_count": 36, 773 | "id": "d8ce2e0b", 774 | "metadata": {}, 775 | "outputs": [ 776 | { 777 | "name": "stdout", 778 | "output_type": "stream", 779 | "text": [ 780 | "[1]\n" 781 | ] 782 | } 783 | ], 784 | "source": [ 785 | "def go(t): # t = q = [0]\n", 786 | " t[0] = 1 # t[0] = 1, t = [1] = q\n", 787 | " \n", 788 | "q = [0]\n", 789 | "# 0\n", 790 | "go(q)\n", 791 | "print(q)" 792 | ] 793 | }, 794 | { 795 | "cell_type": "code", 796 | "execution_count": 37, 797 | "id": "e0d4fe34", 798 | "metadata": {}, 799 | "outputs": [ 800 | { 801 | "name": "stdout", 802 | "output_type": "stream", 803 | "text": [ 804 | "3\n", 805 | "4\n" 806 | ] 807 | } 808 | ], 809 | "source": [ 810 | "def green(red, a):\n", 811 | " print(red(a))\n", 812 | "\n", 813 | "green(max,[1,2,3])\n", 814 | "green(min,[4,5,6])" 815 | ] 816 | }, 817 | { 818 | "cell_type": "code", 819 | "execution_count": 38, 820 | "id": "82edc6cc", 821 | "metadata": {}, 822 | "outputs": [ 823 | { 824 | "name": "stdout", 825 | "output_type": "stream", 826 | "text": [ 827 | "0\n" 828 | ] 829 | } 830 | ], 831 | "source": [ 832 | "def printn(x):\n", 833 | " for i in range(x):\n", 834 | " print(i)\n", 835 | " return\n", 836 | "\n", 837 | "printn(10)" 838 | ] 839 | }, 840 | { 841 | "cell_type": "markdown", 842 | "id": "361a1a86", 843 | "metadata": {}, 844 | "source": [ 845 | "# Lambda function\n", 846 | "\n", 847 | "anonymous function" 848 | ] 849 | }, 850 | { 851 | "cell_type": "code", 852 | "execution_count": 39, 853 | "id": "37f10c3d", 854 | "metadata": {}, 855 | "outputs": [ 856 | { 857 | "name": "stdout", 858 | "output_type": "stream", 859 | "text": [ 860 | "343\n" 861 | ] 862 | } 863 | ], 864 | "source": [ 865 | "def cube(y):\n", 866 | " return y * y * y\n", 867 | "\n", 868 | "\n", 869 | "# lambda argument : statement/expression\n", 870 | "g = lambda x: x * x * x\n", 871 | "\n", 872 | "print(g(7))" 873 | ] 874 | }, 875 | { 876 | "cell_type": "code", 877 | "execution_count": 40, 878 | "id": "a30b53ee", 879 | "metadata": {}, 880 | "outputs": [ 881 | { 882 | "data": { 883 | "text/plain": [ 884 | "343" 885 | ] 886 | }, 887 | "execution_count": 40, 888 | "metadata": {}, 889 | "output_type": "execute_result" 890 | } 891 | ], 892 | "source": [ 893 | "cube(7)" 894 | ] 895 | }, 896 | { 897 | "cell_type": "code", 898 | "execution_count": 41, 899 | "id": "4d299e4b", 900 | "metadata": {}, 901 | "outputs": [ 902 | { 903 | "name": "stdout", 904 | "output_type": "stream", 905 | "text": [ 906 | "7\n", 907 | "None\n" 908 | ] 909 | } 910 | ], 911 | "source": [ 912 | "g = lambda x: print(x)\n", 913 | "\n", 914 | "print(g(7))" 915 | ] 916 | }, 917 | { 918 | "cell_type": "markdown", 919 | "id": "3d73b238", 920 | "metadata": {}, 921 | "source": [ 922 | "# Filter function" 923 | ] 924 | }, 925 | { 926 | "cell_type": "code", 927 | "execution_count": 42, 928 | "id": "755bc6e4", 929 | "metadata": {}, 930 | "outputs": [ 931 | { 932 | "name": "stdout", 933 | "output_type": "stream", 934 | "text": [ 935 | "[22, 44]\n" 936 | ] 937 | } 938 | ], 939 | "source": [ 940 | "n = [11,22,33,44,55]\n", 941 | "\n", 942 | "r = list(filter(lambda x: x%2 == 0 , n))\n", 943 | "\n", 944 | "print(r)" 945 | ] 946 | }, 947 | { 948 | "cell_type": "code", 949 | "execution_count": 43, 950 | "id": "547646b9", 951 | "metadata": {}, 952 | "outputs": [ 953 | { 954 | "name": "stdout", 955 | "output_type": "stream", 956 | "text": [ 957 | "[11, 33, 55]\n" 958 | ] 959 | } 960 | ], 961 | "source": [ 962 | "n = [11,22,33,44,55]\n", 963 | "\n", 964 | "r = list(filter(lambda x: x%2 == 1 , n))\n", 965 | "\n", 966 | "print(r)" 967 | ] 968 | }, 969 | { 970 | "cell_type": "markdown", 971 | "id": "6024f003", 972 | "metadata": {}, 973 | "source": [ 974 | "# map function" 975 | ] 976 | }, 977 | { 978 | "cell_type": "code", 979 | "execution_count": 44, 980 | "id": "fd40e98e", 981 | "metadata": {}, 982 | "outputs": [ 983 | { 984 | "name": "stdout", 985 | "output_type": "stream", 986 | "text": [ 987 | "[6, 7, 8, 9, 10]\n" 988 | ] 989 | } 990 | ], 991 | "source": [ 992 | "n = [1,2,3,4,5]\n", 993 | "\n", 994 | "r = list(map(lambda y: y + 5 , n))\n", 995 | "\n", 996 | "print(r)" 997 | ] 998 | }, 999 | { 1000 | "cell_type": "code", 1001 | "execution_count": 45, 1002 | "id": "624d82ea", 1003 | "metadata": {}, 1004 | "outputs": [ 1005 | { 1006 | "data": { 1007 | "text/plain": [ 1008 | "'INDORE'" 1009 | ] 1010 | }, 1011 | "execution_count": 45, 1012 | "metadata": {}, 1013 | "output_type": "execute_result" 1014 | } 1015 | ], 1016 | "source": [ 1017 | "n = [\"indore\", 'goa', 'vizag']\n", 1018 | "\n", 1019 | "n[0].upper()" 1020 | ] 1021 | }, 1022 | { 1023 | "cell_type": "code", 1024 | "execution_count": 50, 1025 | "id": "25643a01", 1026 | "metadata": { 1027 | "scrolled": false 1028 | }, 1029 | "outputs": [], 1030 | "source": [ 1031 | "# help(str)" 1032 | ] 1033 | }, 1034 | { 1035 | "cell_type": "code", 1036 | "execution_count": 51, 1037 | "id": "02bda1b6", 1038 | "metadata": {}, 1039 | "outputs": [ 1040 | { 1041 | "data": { 1042 | "text/plain": [ 1043 | "'INDIA'" 1044 | ] 1045 | }, 1046 | "execution_count": 51, 1047 | "metadata": {}, 1048 | "output_type": "execute_result" 1049 | } 1050 | ], 1051 | "source": [ 1052 | "\"india\".upper()" 1053 | ] 1054 | }, 1055 | { 1056 | "cell_type": "code", 1057 | "execution_count": 48, 1058 | "id": "6773c993", 1059 | "metadata": {}, 1060 | "outputs": [ 1061 | { 1062 | "name": "stdout", 1063 | "output_type": "stream", 1064 | "text": [ 1065 | "['INDORE', 'GOA', 'VIZAG']\n" 1066 | ] 1067 | } 1068 | ], 1069 | "source": [ 1070 | "def up(a):\n", 1071 | " return a.upper()\n", 1072 | "\n", 1073 | "n = [\"indore\", 'goa', 'vizag']\n", 1074 | "\n", 1075 | "r = list(map(up, n))\n", 1076 | "\n", 1077 | "print(r)" 1078 | ] 1079 | }, 1080 | { 1081 | "cell_type": "code", 1082 | "execution_count": 52, 1083 | "id": "ff001f1e", 1084 | "metadata": {}, 1085 | "outputs": [ 1086 | { 1087 | "name": "stdout", 1088 | "output_type": "stream", 1089 | "text": [ 1090 | "Help on class map in module builtins:\n", 1091 | "\n", 1092 | "class map(object)\n", 1093 | " | map(func, *iterables) --> map object\n", 1094 | " | \n", 1095 | " | Make an iterator that computes the function using arguments from\n", 1096 | " | each of the iterables. Stops when the shortest iterable is exhausted.\n", 1097 | " | \n", 1098 | " | Methods defined here:\n", 1099 | " | \n", 1100 | " | __getattribute__(self, name, /)\n", 1101 | " | Return getattr(self, name).\n", 1102 | " | \n", 1103 | " | __iter__(self, /)\n", 1104 | " | Implement iter(self).\n", 1105 | " | \n", 1106 | " | __next__(self, /)\n", 1107 | " | Implement next(self).\n", 1108 | " | \n", 1109 | " | __reduce__(...)\n", 1110 | " | Return state information for pickling.\n", 1111 | " | \n", 1112 | " | ----------------------------------------------------------------------\n", 1113 | " | Static methods defined here:\n", 1114 | " | \n", 1115 | " | __new__(*args, **kwargs) from builtins.type\n", 1116 | " | Create and return a new object. See help(type) for accurate signature.\n", 1117 | "\n" 1118 | ] 1119 | } 1120 | ], 1121 | "source": [ 1122 | "help(map)" 1123 | ] 1124 | }, 1125 | { 1126 | "cell_type": "markdown", 1127 | "id": "f07c7946", 1128 | "metadata": {}, 1129 | "source": [ 1130 | "# Closuers" 1131 | ] 1132 | }, 1133 | { 1134 | "cell_type": "code", 1135 | "execution_count": 53, 1136 | "id": "98a47a83", 1137 | "metadata": {}, 1138 | "outputs": [], 1139 | "source": [ 1140 | "def add_ten():\n", 1141 | " ten = 10\n", 1142 | " \n", 1143 | " def add(n):\n", 1144 | " return n + ten\n", 1145 | " \n", 1146 | " return add" 1147 | ] 1148 | }, 1149 | { 1150 | "cell_type": "code", 1151 | "execution_count": 54, 1152 | "id": "5f78a373", 1153 | "metadata": {}, 1154 | "outputs": [ 1155 | { 1156 | "name": "stdout", 1157 | "output_type": "stream", 1158 | "text": [ 1159 | "15\n" 1160 | ] 1161 | } 1162 | ], 1163 | "source": [ 1164 | "clouser_result = add_ten()\n", 1165 | "\n", 1166 | "print(clouser_result(5))\n", 1167 | "# add(5)" 1168 | ] 1169 | }, 1170 | { 1171 | "cell_type": "code", 1172 | "execution_count": 55, 1173 | "id": "565827f6", 1174 | "metadata": {}, 1175 | "outputs": [ 1176 | { 1177 | "name": "stdout", 1178 | "output_type": "stream", 1179 | "text": [ 1180 | "20\n" 1181 | ] 1182 | } 1183 | ], 1184 | "source": [ 1185 | "print(clouser_result(10))" 1186 | ] 1187 | }, 1188 | { 1189 | "cell_type": "markdown", 1190 | "id": "b4f3a26c", 1191 | "metadata": {}, 1192 | "source": [ 1193 | "# Decorators" 1194 | ] 1195 | }, 1196 | { 1197 | "cell_type": "code", 1198 | "execution_count": 57, 1199 | "id": "7f12459c", 1200 | "metadata": { 1201 | "scrolled": false 1202 | }, 1203 | "outputs": [], 1204 | "source": [ 1205 | "# help(str)" 1206 | ] 1207 | }, 1208 | { 1209 | "cell_type": "code", 1210 | "execution_count": 58, 1211 | "id": "3c579a09", 1212 | "metadata": {}, 1213 | "outputs": [ 1214 | { 1215 | "name": "stdout", 1216 | "output_type": "stream", 1217 | "text": [ 1218 | "HELLO HOW ARE YOU? WELCOME\n" 1219 | ] 1220 | } 1221 | ], 1222 | "source": [ 1223 | "def greeting():\n", 1224 | " return \"Hello How are you? Welcome\"\n", 1225 | "\n", 1226 | "def uppercase_decorator(function):\n", 1227 | " def wrapper():\n", 1228 | " f = function()\n", 1229 | " u = f.upper()\n", 1230 | " return u\n", 1231 | " return wrapper\n", 1232 | "\n", 1233 | "g = uppercase_decorator(greeting)\n", 1234 | "print(g())" 1235 | ] 1236 | }, 1237 | { 1238 | "cell_type": "code", 1239 | "execution_count": 59, 1240 | "id": "a5b98d6f", 1241 | "metadata": {}, 1242 | "outputs": [ 1243 | { 1244 | "name": "stdout", 1245 | "output_type": "stream", 1246 | "text": [ 1247 | "WELCOME HERE\n" 1248 | ] 1249 | } 1250 | ], 1251 | "source": [ 1252 | "def uppercase_decorator(function):\n", 1253 | " def wrapper():\n", 1254 | " f = function()\n", 1255 | " u = f.upper()\n", 1256 | " return u\n", 1257 | " return wrapper\n", 1258 | "\n", 1259 | "@uppercase_decorator\n", 1260 | "def greeting():\n", 1261 | " return 'Welcome here'\n", 1262 | "\n", 1263 | "\n", 1264 | "print(greeting())" 1265 | ] 1266 | }, 1267 | { 1268 | "cell_type": "code", 1269 | "execution_count": null, 1270 | "id": "97c568f1", 1271 | "metadata": {}, 1272 | "outputs": [], 1273 | "source": [] 1274 | } 1275 | ], 1276 | "metadata": { 1277 | "kernelspec": { 1278 | "display_name": "Python 3 (ipykernel)", 1279 | "language": "python", 1280 | "name": "python3" 1281 | }, 1282 | "language_info": { 1283 | "codemirror_mode": { 1284 | "name": "ipython", 1285 | "version": 3 1286 | }, 1287 | "file_extension": ".py", 1288 | "mimetype": "text/x-python", 1289 | "name": "python", 1290 | "nbconvert_exporter": "python", 1291 | "pygments_lexer": "ipython3", 1292 | "version": "3.9.12" 1293 | } 1294 | }, 1295 | "nbformat": 4, 1296 | "nbformat_minor": 5 1297 | } 1298 | -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/.ipynb_checkpoints/5_Modules and Packages-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "69d81e58", 6 | "metadata": {}, 7 | "source": [ 8 | "# OS" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "b7ff5795", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import os" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 3, 24 | "id": "c9ada02d", 25 | "metadata": { 26 | "scrolled": false 27 | }, 28 | "outputs": [], 29 | "source": [ 30 | "# help(os)" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": 4, 36 | "id": "66cc382b", 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [ 40 | "# make directory\n", 41 | "\n", 42 | "os.mkdir('images')" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": 5, 48 | "id": "8b465dfe", 49 | "metadata": {}, 50 | "outputs": [ 51 | { 52 | "data": { 53 | "text/plain": [ 54 | "'C:\\\\Users\\\\himan\\\\Documents\\\\Himanshu Ramchandani Live\\\\Python-For-Data-Professionals\\\\05_Modules, Packages, PIP'" 55 | ] 56 | }, 57 | "execution_count": 5, 58 | "metadata": {}, 59 | "output_type": "execute_result" 60 | } 61 | ], 62 | "source": [ 63 | "# get current working directory\n", 64 | "\n", 65 | "os.getcwd()" 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": 6, 71 | "id": "79ff96c3", 72 | "metadata": {}, 73 | "outputs": [], 74 | "source": [ 75 | "# remove directory\n", 76 | "\n", 77 | "os.rmdir('images')" 78 | ] 79 | }, 80 | { 81 | "cell_type": "markdown", 82 | "id": "0ed24bf4", 83 | "metadata": {}, 84 | "source": [ 85 | "# sys" 86 | ] 87 | }, 88 | { 89 | "cell_type": "code", 90 | "execution_count": 7, 91 | "id": "e5ad4f54", 92 | "metadata": {}, 93 | "outputs": [ 94 | { 95 | "name": "stdout", 96 | "output_type": "stream", 97 | "text": [ 98 | "3\n" 99 | ] 100 | } 101 | ], 102 | "source": [ 103 | "import sys\n", 104 | "\n", 105 | "a = 3000\n", 106 | "\n", 107 | "print(sys.getrefcount(a))" 108 | ] 109 | }, 110 | { 111 | "cell_type": "code", 112 | "execution_count": 10, 113 | "id": "5b7aeb16", 114 | "metadata": {}, 115 | "outputs": [ 116 | { 117 | "name": "stdout", 118 | "output_type": "stream", 119 | "text": [ 120 | "2547\n", 121 | "2546\n" 122 | ] 123 | } 124 | ], 125 | "source": [ 126 | "a = 10\n", 127 | "b = a\n", 128 | "print(sys.getrefcount(a))\n", 129 | "del a\n", 130 | "print(sys.getrefcount(b))" 131 | ] 132 | }, 133 | { 134 | "cell_type": "code", 135 | "execution_count": 11, 136 | "id": "7f7f8b99", 137 | "metadata": {}, 138 | "outputs": [ 139 | { 140 | "data": { 141 | "text/plain": [ 142 | "9223372036854775807" 143 | ] 144 | }, 145 | "execution_count": 11, 146 | "metadata": {}, 147 | "output_type": "execute_result" 148 | } 149 | ], 150 | "source": [ 151 | "sys.maxsize" 152 | ] 153 | }, 154 | { 155 | "cell_type": "code", 156 | "execution_count": 13, 157 | "id": "d98874de", 158 | "metadata": { 159 | "scrolled": false 160 | }, 161 | "outputs": [], 162 | "source": [ 163 | "# help(sys.maxsize)" 164 | ] 165 | }, 166 | { 167 | "cell_type": "code", 168 | "execution_count": 14, 169 | "id": "971e5935", 170 | "metadata": {}, 171 | "outputs": [ 172 | { 173 | "data": { 174 | "text/plain": [ 175 | "['C:\\\\Users\\\\himan\\\\Documents\\\\Himanshu Ramchandani Live\\\\Python-For-Data-Professionals\\\\05_Modules, Packages, PIP',\n", 176 | " 'C:\\\\Users\\\\himan\\\\anaconda3\\\\python39.zip',\n", 177 | " 'C:\\\\Users\\\\himan\\\\anaconda3\\\\DLLs',\n", 178 | " 'C:\\\\Users\\\\himan\\\\anaconda3\\\\lib',\n", 179 | " 'C:\\\\Users\\\\himan\\\\anaconda3',\n", 180 | " '',\n", 181 | " 'C:\\\\Users\\\\himan\\\\anaconda3\\\\lib\\\\site-packages',\n", 182 | " 'C:\\\\Users\\\\himan\\\\anaconda3\\\\lib\\\\site-packages\\\\win32',\n", 183 | " 'C:\\\\Users\\\\himan\\\\anaconda3\\\\lib\\\\site-packages\\\\win32\\\\lib',\n", 184 | " 'C:\\\\Users\\\\himan\\\\anaconda3\\\\lib\\\\site-packages\\\\Pythonwin']" 185 | ] 186 | }, 187 | "execution_count": 14, 188 | "metadata": {}, 189 | "output_type": "execute_result" 190 | } 191 | ], 192 | "source": [ 193 | "sys.path" 194 | ] 195 | }, 196 | { 197 | "cell_type": "code", 198 | "execution_count": 15, 199 | "id": "4f61c73f", 200 | "metadata": {}, 201 | "outputs": [ 202 | { 203 | "data": { 204 | "text/plain": [ 205 | "'3.9.12 (main, Apr 4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)]'" 206 | ] 207 | }, 208 | "execution_count": 15, 209 | "metadata": {}, 210 | "output_type": "execute_result" 211 | } 212 | ], 213 | "source": [ 214 | "sys.version" 215 | ] 216 | }, 217 | { 218 | "cell_type": "markdown", 219 | "id": "159a5351", 220 | "metadata": {}, 221 | "source": [ 222 | "# statistics" 223 | ] 224 | }, 225 | { 226 | "cell_type": "code", 227 | "execution_count": 16, 228 | "id": "4b5b70f2", 229 | "metadata": {}, 230 | "outputs": [], 231 | "source": [ 232 | "from statistics import *" 233 | ] 234 | }, 235 | { 236 | "cell_type": "code", 237 | "execution_count": 17, 238 | "id": "80b96f86", 239 | "metadata": {}, 240 | "outputs": [ 241 | { 242 | "name": "stdout", 243 | "output_type": "stream", 244 | "text": [ 245 | "35.666666666666664\n" 246 | ] 247 | } 248 | ], 249 | "source": [ 250 | "ages = [20,10,40,33,45,66]\n", 251 | "\n", 252 | "print(mean(ages))" 253 | ] 254 | }, 255 | { 256 | "cell_type": "code", 257 | "execution_count": 18, 258 | "id": "b036724c", 259 | "metadata": {}, 260 | "outputs": [ 261 | { 262 | "name": "stdout", 263 | "output_type": "stream", 264 | "text": [ 265 | "36.5\n" 266 | ] 267 | } 268 | ], 269 | "source": [ 270 | "print(median(ages))" 271 | ] 272 | }, 273 | { 274 | "cell_type": "code", 275 | "execution_count": 19, 276 | "id": "d431b2bf", 277 | "metadata": {}, 278 | "outputs": [ 279 | { 280 | "name": "stdout", 281 | "output_type": "stream", 282 | "text": [ 283 | "20\n" 284 | ] 285 | } 286 | ], 287 | "source": [ 288 | "print(mode(ages))" 289 | ] 290 | }, 291 | { 292 | "cell_type": "code", 293 | "execution_count": 20, 294 | "id": "d15f0ae6", 295 | "metadata": {}, 296 | "outputs": [ 297 | { 298 | "name": "stdout", 299 | "output_type": "stream", 300 | "text": [ 301 | "19.684172999307506\n" 302 | ] 303 | } 304 | ], 305 | "source": [ 306 | "print(stdev(ages))" 307 | ] 308 | }, 309 | { 310 | "cell_type": "markdown", 311 | "id": "7b3a5cdc", 312 | "metadata": {}, 313 | "source": [ 314 | "# math" 315 | ] 316 | }, 317 | { 318 | "cell_type": "code", 319 | "execution_count": 21, 320 | "id": "5fc6cf2f", 321 | "metadata": {}, 322 | "outputs": [], 323 | "source": [ 324 | "import math" 325 | ] 326 | }, 327 | { 328 | "cell_type": "code", 329 | "execution_count": 22, 330 | "id": "7e1ed80d", 331 | "metadata": {}, 332 | "outputs": [ 333 | { 334 | "name": "stdout", 335 | "output_type": "stream", 336 | "text": [ 337 | "3.141592653589793\n" 338 | ] 339 | } 340 | ], 341 | "source": [ 342 | "print(math.pi)" 343 | ] 344 | }, 345 | { 346 | "cell_type": "code", 347 | "execution_count": 23, 348 | "id": "af02d2fa", 349 | "metadata": {}, 350 | "outputs": [ 351 | { 352 | "name": "stdout", 353 | "output_type": "stream", 354 | "text": [ 355 | "1.4142135623730951\n" 356 | ] 357 | } 358 | ], 359 | "source": [ 360 | "print(math.sqrt(2))" 361 | ] 362 | }, 363 | { 364 | "cell_type": "code", 365 | "execution_count": 24, 366 | "id": "9456d930", 367 | "metadata": {}, 368 | "outputs": [ 369 | { 370 | "name": "stdout", 371 | "output_type": "stream", 372 | "text": [ 373 | "8.0\n" 374 | ] 375 | } 376 | ], 377 | "source": [ 378 | "print(math.pow(2,3))" 379 | ] 380 | }, 381 | { 382 | "cell_type": "code", 383 | "execution_count": 25, 384 | "id": "c0f548af", 385 | "metadata": {}, 386 | "outputs": [ 387 | { 388 | "name": "stdout", 389 | "output_type": "stream", 390 | "text": [ 391 | "3\n" 392 | ] 393 | } 394 | ], 395 | "source": [ 396 | "print(math.floor(3.4))" 397 | ] 398 | }, 399 | { 400 | "cell_type": "code", 401 | "execution_count": 26, 402 | "id": "ca20219e", 403 | "metadata": {}, 404 | "outputs": [ 405 | { 406 | "name": "stdout", 407 | "output_type": "stream", 408 | "text": [ 409 | "4\n" 410 | ] 411 | } 412 | ], 413 | "source": [ 414 | "print(math.ceil(3.5))" 415 | ] 416 | }, 417 | { 418 | "cell_type": "code", 419 | "execution_count": 27, 420 | "id": "436a9486", 421 | "metadata": {}, 422 | "outputs": [], 423 | "source": [ 424 | "# from math import pi, sqrt, pow, floor, ceil" 425 | ] 426 | }, 427 | { 428 | "cell_type": "markdown", 429 | "id": "dc1e17e4", 430 | "metadata": {}, 431 | "source": [ 432 | "# random" 433 | ] 434 | }, 435 | { 436 | "cell_type": "code", 437 | "execution_count": 28, 438 | "id": "fe6cef78", 439 | "metadata": {}, 440 | "outputs": [], 441 | "source": [ 442 | "import random as r" 443 | ] 444 | }, 445 | { 446 | "cell_type": "code", 447 | "execution_count": 30, 448 | "id": "27c3ad84", 449 | "metadata": {}, 450 | "outputs": [ 451 | { 452 | "name": "stdout", 453 | "output_type": "stream", 454 | "text": [ 455 | "0.5506872242436001\n" 456 | ] 457 | } 458 | ], 459 | "source": [ 460 | "print(r.random()) # 0 to 1" 461 | ] 462 | }, 463 | { 464 | "cell_type": "code", 465 | "execution_count": 35, 466 | "id": "13732f60", 467 | "metadata": {}, 468 | "outputs": [ 469 | { 470 | "name": "stdout", 471 | "output_type": "stream", 472 | "text": [ 473 | "13\n" 474 | ] 475 | } 476 | ], 477 | "source": [ 478 | "print(r.randint(5,20))" 479 | ] 480 | }, 481 | { 482 | "cell_type": "code", 483 | "execution_count": null, 484 | "id": "22c7f79f", 485 | "metadata": {}, 486 | "outputs": [], 487 | "source": [ 488 | "bit > numbers > characters > instructions > function > class > module > package > library > framework" 489 | ] 490 | } 491 | ], 492 | "metadata": { 493 | "kernelspec": { 494 | "display_name": "Python 3 (ipykernel)", 495 | "language": "python", 496 | "name": "python3" 497 | }, 498 | "language_info": { 499 | "codemirror_mode": { 500 | "name": "ipython", 501 | "version": 3 502 | }, 503 | "file_extension": ".py", 504 | "mimetype": "text/x-python", 505 | "name": "python", 506 | "nbconvert_exporter": "python", 507 | "pygments_lexer": "ipython3", 508 | "version": "3.9.12" 509 | } 510 | }, 511 | "nbformat": 4, 512 | "nbformat_minor": 5 513 | } 514 | -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/5_Modules and Packages.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "69d81e58", 6 | "metadata": {}, 7 | "source": [ 8 | "# OS" 9 | ] 10 | }, 11 | { 12 | "cell_type": "code", 13 | "execution_count": 1, 14 | "id": "b7ff5795", 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import os" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 3, 24 | "id": "c9ada02d", 25 | "metadata": { 26 | "scrolled": false 27 | }, 28 | "outputs": [], 29 | "source": [ 30 | "# help(os)" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": 4, 36 | "id": "66cc382b", 37 | "metadata": {}, 38 | "outputs": [], 39 | "source": [ 40 | "# make directory\n", 41 | "\n", 42 | "os.mkdir('images')" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": 5, 48 | "id": "8b465dfe", 49 | "metadata": {}, 50 | "outputs": [ 51 | { 52 | "data": { 53 | "text/plain": [ 54 | "'C:\\\\Users\\\\himan\\\\Documents\\\\Himanshu Ramchandani Live\\\\Python-For-Data-Professionals\\\\05_Modules, Packages, PIP'" 55 | ] 56 | }, 57 | "execution_count": 5, 58 | "metadata": {}, 59 | "output_type": "execute_result" 60 | } 61 | ], 62 | "source": [ 63 | "# get current working directory\n", 64 | "\n", 65 | "os.getcwd()" 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": 6, 71 | "id": "79ff96c3", 72 | "metadata": {}, 73 | "outputs": [], 74 | "source": [ 75 | "# remove directory\n", 76 | "\n", 77 | "os.rmdir('images')" 78 | ] 79 | }, 80 | { 81 | "cell_type": "markdown", 82 | "id": "0ed24bf4", 83 | "metadata": {}, 84 | "source": [ 85 | "# sys" 86 | ] 87 | }, 88 | { 89 | "cell_type": "code", 90 | "execution_count": 7, 91 | "id": "e5ad4f54", 92 | "metadata": {}, 93 | "outputs": [ 94 | { 95 | "name": "stdout", 96 | "output_type": "stream", 97 | "text": [ 98 | "3\n" 99 | ] 100 | } 101 | ], 102 | "source": [ 103 | "import sys\n", 104 | "\n", 105 | "a = 3000\n", 106 | "\n", 107 | "print(sys.getrefcount(a))" 108 | ] 109 | }, 110 | { 111 | "cell_type": "code", 112 | "execution_count": 10, 113 | "id": "5b7aeb16", 114 | "metadata": {}, 115 | "outputs": [ 116 | { 117 | "name": "stdout", 118 | "output_type": "stream", 119 | "text": [ 120 | "2547\n", 121 | "2546\n" 122 | ] 123 | } 124 | ], 125 | "source": [ 126 | "a = 10\n", 127 | "b = a\n", 128 | "print(sys.getrefcount(a))\n", 129 | "del a\n", 130 | "print(sys.getrefcount(b))" 131 | ] 132 | }, 133 | { 134 | "cell_type": "code", 135 | "execution_count": 11, 136 | "id": "7f7f8b99", 137 | "metadata": {}, 138 | "outputs": [ 139 | { 140 | "data": { 141 | "text/plain": [ 142 | "9223372036854775807" 143 | ] 144 | }, 145 | "execution_count": 11, 146 | "metadata": {}, 147 | "output_type": "execute_result" 148 | } 149 | ], 150 | "source": [ 151 | "sys.maxsize" 152 | ] 153 | }, 154 | { 155 | "cell_type": "code", 156 | "execution_count": 13, 157 | "id": "d98874de", 158 | "metadata": { 159 | "scrolled": false 160 | }, 161 | "outputs": [], 162 | "source": [ 163 | "# help(sys.maxsize)" 164 | ] 165 | }, 166 | { 167 | "cell_type": "code", 168 | "execution_count": 14, 169 | "id": "971e5935", 170 | "metadata": {}, 171 | "outputs": [ 172 | { 173 | "data": { 174 | "text/plain": [ 175 | "['C:\\\\Users\\\\himan\\\\Documents\\\\Himanshu Ramchandani Live\\\\Python-For-Data-Professionals\\\\05_Modules, Packages, PIP',\n", 176 | " 'C:\\\\Users\\\\himan\\\\anaconda3\\\\python39.zip',\n", 177 | " 'C:\\\\Users\\\\himan\\\\anaconda3\\\\DLLs',\n", 178 | " 'C:\\\\Users\\\\himan\\\\anaconda3\\\\lib',\n", 179 | " 'C:\\\\Users\\\\himan\\\\anaconda3',\n", 180 | " '',\n", 181 | " 'C:\\\\Users\\\\himan\\\\anaconda3\\\\lib\\\\site-packages',\n", 182 | " 'C:\\\\Users\\\\himan\\\\anaconda3\\\\lib\\\\site-packages\\\\win32',\n", 183 | " 'C:\\\\Users\\\\himan\\\\anaconda3\\\\lib\\\\site-packages\\\\win32\\\\lib',\n", 184 | " 'C:\\\\Users\\\\himan\\\\anaconda3\\\\lib\\\\site-packages\\\\Pythonwin']" 185 | ] 186 | }, 187 | "execution_count": 14, 188 | "metadata": {}, 189 | "output_type": "execute_result" 190 | } 191 | ], 192 | "source": [ 193 | "sys.path" 194 | ] 195 | }, 196 | { 197 | "cell_type": "code", 198 | "execution_count": 15, 199 | "id": "4f61c73f", 200 | "metadata": {}, 201 | "outputs": [ 202 | { 203 | "data": { 204 | "text/plain": [ 205 | "'3.9.12 (main, Apr 4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)]'" 206 | ] 207 | }, 208 | "execution_count": 15, 209 | "metadata": {}, 210 | "output_type": "execute_result" 211 | } 212 | ], 213 | "source": [ 214 | "sys.version" 215 | ] 216 | }, 217 | { 218 | "cell_type": "markdown", 219 | "id": "159a5351", 220 | "metadata": {}, 221 | "source": [ 222 | "# statistics" 223 | ] 224 | }, 225 | { 226 | "cell_type": "code", 227 | "execution_count": 16, 228 | "id": "4b5b70f2", 229 | "metadata": {}, 230 | "outputs": [], 231 | "source": [ 232 | "from statistics import *" 233 | ] 234 | }, 235 | { 236 | "cell_type": "code", 237 | "execution_count": 17, 238 | "id": "80b96f86", 239 | "metadata": {}, 240 | "outputs": [ 241 | { 242 | "name": "stdout", 243 | "output_type": "stream", 244 | "text": [ 245 | "35.666666666666664\n" 246 | ] 247 | } 248 | ], 249 | "source": [ 250 | "ages = [20,10,40,33,45,66]\n", 251 | "\n", 252 | "print(mean(ages))" 253 | ] 254 | }, 255 | { 256 | "cell_type": "code", 257 | "execution_count": 18, 258 | "id": "b036724c", 259 | "metadata": {}, 260 | "outputs": [ 261 | { 262 | "name": "stdout", 263 | "output_type": "stream", 264 | "text": [ 265 | "36.5\n" 266 | ] 267 | } 268 | ], 269 | "source": [ 270 | "print(median(ages))" 271 | ] 272 | }, 273 | { 274 | "cell_type": "code", 275 | "execution_count": 19, 276 | "id": "d431b2bf", 277 | "metadata": {}, 278 | "outputs": [ 279 | { 280 | "name": "stdout", 281 | "output_type": "stream", 282 | "text": [ 283 | "20\n" 284 | ] 285 | } 286 | ], 287 | "source": [ 288 | "print(mode(ages))" 289 | ] 290 | }, 291 | { 292 | "cell_type": "code", 293 | "execution_count": 20, 294 | "id": "d15f0ae6", 295 | "metadata": {}, 296 | "outputs": [ 297 | { 298 | "name": "stdout", 299 | "output_type": "stream", 300 | "text": [ 301 | "19.684172999307506\n" 302 | ] 303 | } 304 | ], 305 | "source": [ 306 | "print(stdev(ages))" 307 | ] 308 | }, 309 | { 310 | "cell_type": "markdown", 311 | "id": "7b3a5cdc", 312 | "metadata": {}, 313 | "source": [ 314 | "# math" 315 | ] 316 | }, 317 | { 318 | "cell_type": "code", 319 | "execution_count": 21, 320 | "id": "5fc6cf2f", 321 | "metadata": {}, 322 | "outputs": [], 323 | "source": [ 324 | "import math" 325 | ] 326 | }, 327 | { 328 | "cell_type": "code", 329 | "execution_count": 22, 330 | "id": "7e1ed80d", 331 | "metadata": {}, 332 | "outputs": [ 333 | { 334 | "name": "stdout", 335 | "output_type": "stream", 336 | "text": [ 337 | "3.141592653589793\n" 338 | ] 339 | } 340 | ], 341 | "source": [ 342 | "print(math.pi)" 343 | ] 344 | }, 345 | { 346 | "cell_type": "code", 347 | "execution_count": 23, 348 | "id": "af02d2fa", 349 | "metadata": {}, 350 | "outputs": [ 351 | { 352 | "name": "stdout", 353 | "output_type": "stream", 354 | "text": [ 355 | "1.4142135623730951\n" 356 | ] 357 | } 358 | ], 359 | "source": [ 360 | "print(math.sqrt(2))" 361 | ] 362 | }, 363 | { 364 | "cell_type": "code", 365 | "execution_count": 24, 366 | "id": "9456d930", 367 | "metadata": {}, 368 | "outputs": [ 369 | { 370 | "name": "stdout", 371 | "output_type": "stream", 372 | "text": [ 373 | "8.0\n" 374 | ] 375 | } 376 | ], 377 | "source": [ 378 | "print(math.pow(2,3))" 379 | ] 380 | }, 381 | { 382 | "cell_type": "code", 383 | "execution_count": 25, 384 | "id": "c0f548af", 385 | "metadata": {}, 386 | "outputs": [ 387 | { 388 | "name": "stdout", 389 | "output_type": "stream", 390 | "text": [ 391 | "3\n" 392 | ] 393 | } 394 | ], 395 | "source": [ 396 | "print(math.floor(3.4))" 397 | ] 398 | }, 399 | { 400 | "cell_type": "code", 401 | "execution_count": 26, 402 | "id": "ca20219e", 403 | "metadata": {}, 404 | "outputs": [ 405 | { 406 | "name": "stdout", 407 | "output_type": "stream", 408 | "text": [ 409 | "4\n" 410 | ] 411 | } 412 | ], 413 | "source": [ 414 | "print(math.ceil(3.5))" 415 | ] 416 | }, 417 | { 418 | "cell_type": "code", 419 | "execution_count": 27, 420 | "id": "436a9486", 421 | "metadata": {}, 422 | "outputs": [], 423 | "source": [ 424 | "# from math import pi, sqrt, pow, floor, ceil" 425 | ] 426 | }, 427 | { 428 | "cell_type": "markdown", 429 | "id": "dc1e17e4", 430 | "metadata": {}, 431 | "source": [ 432 | "# random" 433 | ] 434 | }, 435 | { 436 | "cell_type": "code", 437 | "execution_count": 28, 438 | "id": "fe6cef78", 439 | "metadata": {}, 440 | "outputs": [], 441 | "source": [ 442 | "import random as r" 443 | ] 444 | }, 445 | { 446 | "cell_type": "code", 447 | "execution_count": 30, 448 | "id": "27c3ad84", 449 | "metadata": {}, 450 | "outputs": [ 451 | { 452 | "name": "stdout", 453 | "output_type": "stream", 454 | "text": [ 455 | "0.5506872242436001\n" 456 | ] 457 | } 458 | ], 459 | "source": [ 460 | "print(r.random()) # 0 to 1" 461 | ] 462 | }, 463 | { 464 | "cell_type": "code", 465 | "execution_count": 35, 466 | "id": "13732f60", 467 | "metadata": {}, 468 | "outputs": [ 469 | { 470 | "name": "stdout", 471 | "output_type": "stream", 472 | "text": [ 473 | "13\n" 474 | ] 475 | } 476 | ], 477 | "source": [ 478 | "print(r.randint(5,20))" 479 | ] 480 | }, 481 | { 482 | "cell_type": "code", 483 | "execution_count": null, 484 | "id": "22c7f79f", 485 | "metadata": {}, 486 | "outputs": [], 487 | "source": [ 488 | "bit > numbers > characters > instructions > function > class > module > package > library > framework" 489 | ] 490 | } 491 | ], 492 | "metadata": { 493 | "kernelspec": { 494 | "display_name": "Python 3 (ipykernel)", 495 | "language": "python", 496 | "name": "python3" 497 | }, 498 | "language_info": { 499 | "codemirror_mode": { 500 | "name": "ipython", 501 | "version": 3 502 | }, 503 | "file_extension": ".py", 504 | "mimetype": "text/x-python", 505 | "name": "python", 506 | "nbconvert_exporter": "python", 507 | "pygments_lexer": "ipython3", 508 | "version": "3.9.12" 509 | } 510 | }, 511 | "nbformat": 4, 512 | "nbformat_minor": 5 513 | } 514 | -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/main.py: -------------------------------------------------------------------------------- 1 | # import maths 2 | 3 | # print(help(maths)) 4 | 5 | # print(maths.pie) 6 | 7 | # print(maths.hello()) 8 | 9 | 10 | from descriptive.dstatistics import DesciptiveStatistics 11 | # from sklearn.model_selection import LinearRegression 12 | 13 | d = DesciptiveStatistics() 14 | 15 | print(d.mean([1,2,3,4,5])) 16 | 17 | # print(help(d.mean)) 18 | 19 | from inferential.istatitstics import InferentialStatistics 20 | 21 | i = InferentialStatistics() 22 | 23 | print(i.Hypothesis()) 24 | 25 | # from inferential import istatitstics 26 | 27 | # e = istatitstics.InferentialStatistics() 28 | 29 | # print() -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/05_Modules, Packages, PIP/mathematics-meme/LICENSE.txt -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/README.rst: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/05_Modules, Packages, PIP/mathematics-meme/README.rst -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/__pycache__/maths.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/05_Modules, Packages, PIP/mathematics-meme/__pycache__/maths.cpython-310.pyc -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/dist/mathematics-meme-0.2.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/05_Modules, Packages, PIP/mathematics-meme/dist/mathematics-meme-0.2.tar.gz -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description-file=README.rst 3 | license_files=LICENSE.txt -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | setup( 4 | 5 | name='mathematics-meme', 6 | version='0.2', 7 | license='MIT', 8 | author='Himanshu Ramchandani', 9 | author_email='himanshuramchandani08@gmail.com', 10 | packages=find_packages('src'), 11 | package_dir={'': 'src'}, 12 | keywords='mathematics meme', 13 | ) -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/src/descriptive/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/05_Modules, Packages, PIP/mathematics-meme/src/descriptive/__init__.py -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/src/descriptive/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/05_Modules, Packages, PIP/mathematics-meme/src/descriptive/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/src/descriptive/__pycache__/dstatistics.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/05_Modules, Packages, PIP/mathematics-meme/src/descriptive/__pycache__/dstatistics.cpython-310.pyc -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/src/descriptive/dstatistics.py: -------------------------------------------------------------------------------- 1 | def doc(): 2 | print(""" 3 | dstatistics - all the operations of decriptive stats 4 | """) 5 | 6 | class DesciptiveStatistics: 7 | 8 | def mean(self, l): 9 | """ 10 | this mean method from DescriptiveStatistics class 11 | will print mean of a list. 12 | """ 13 | return sum(l)/len(l) 14 | -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/src/inferential/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/05_Modules, Packages, PIP/mathematics-meme/src/inferential/__init__.py -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/src/inferential/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/05_Modules, Packages, PIP/mathematics-meme/src/inferential/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/src/inferential/__pycache__/istatitstics.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/05_Modules, Packages, PIP/mathematics-meme/src/inferential/__pycache__/istatitstics.cpython-310.pyc -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/src/inferential/istatitstics.py: -------------------------------------------------------------------------------- 1 | class InferentialStatistics: 2 | 3 | def Hypothesis(self): 4 | return "Hypothesis from Inferential Statistics" 5 | 6 | -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/src/mathematics_meme.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: mathematics-meme 3 | Version: 0.2 4 | Author: Himanshu Ramchandani 5 | Author-email: himanshuramchandani08@gmail.com 6 | License: MIT 7 | Keywords: mathematics meme 8 | License-File: LICENSE.txt 9 | -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/src/mathematics_meme.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | LICENSE.txt 2 | README.rst 3 | setup.cfg 4 | setup.py 5 | src/descriptive/__init__.py 6 | src/descriptive/dstatistics.py 7 | src/inferential/__init__.py 8 | src/inferential/istatitstics.py 9 | src/mathematics_meme.egg-info/PKG-INFO 10 | src/mathematics_meme.egg-info/SOURCES.txt 11 | src/mathematics_meme.egg-info/dependency_links.txt 12 | src/mathematics_meme.egg-info/top_level.txt -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/src/mathematics_meme.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/src/mathematics_meme.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | descriptive 2 | inferential 3 | -------------------------------------------------------------------------------- /05_Modules, Packages, PIP/mathematics-meme/src/maths.py: -------------------------------------------------------------------------------- 1 | pie = 3.14 2 | 3 | def summ(x,y): 4 | return x + y 5 | 6 | def hello(): 7 | return "Hello from Maths Module" -------------------------------------------------------------------------------- /06_Virtual Environment, Flask, Web Scrapping/model_building/application.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template 2 | import requests 3 | from bs4 import BeautifulSoup 4 | 5 | app = Flask(__name__) # __main__ 6 | 7 | url = 'https://archive.ics.uci.edu/ml/datasets.php' 8 | 9 | response = requests.get(url) 10 | 11 | status = response.status_code 12 | 13 | content = response.content 14 | soup = BeautifulSoup(content, 'html.parser') 15 | print(soup.body) 16 | 17 | @app.route('/') 18 | def index(): 19 | return "Hello from Index of My Flask App" 20 | 21 | @app.route('/status') 22 | def india(): 23 | return "Hello" 24 | 25 | @app.route('/profile') 26 | def profile(): 27 | name = "Himanshu Ramchandani" 28 | return render_template('index.html', n = name) 29 | 30 | if __name__ == '__main__': 31 | app.run(port=5000) 32 | 33 | 34 | # https://github.com/hemansnation 35 | # scheme DNS / routes 36 | # Domain Name System 37 | -------------------------------------------------------------------------------- /06_Virtual Environment, Flask, Web Scrapping/model_building/main.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template 2 | import os 3 | import pymongo 4 | 5 | MONGODB_URI = 'mongodb+srv://himanshu:him12345@cluster0.z9357pa.mongodb.net/?retryWrites=true&w=majority' 6 | 7 | client = pymongo.MongoClient(MONGODB_URI) 8 | 9 | print(client.list_Database_names()) 10 | 11 | app = Flask(__name__) 12 | 13 | if __name__ == '__main__': 14 | port = int(os.environ.get("PORT", 5000)) 15 | app.run(port=port) -------------------------------------------------------------------------------- /06_Virtual Environment, Flask, Web Scrapping/model_building/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 |

Profile

10 |
11 |

Name:

12 |

13 | {{ n }} 14 |

15 | 16 | -------------------------------------------------------------------------------- /07_Building API, Python with MongoDB Database/model_building/app.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | 3 | url = "https://archive.ics.uci.edu/ml/machine-learning-databases/balloons/adult-stretch.data" 4 | 5 | df = pd.read_csv(url) 6 | 7 | print(df) -------------------------------------------------------------------------------- /07_Building API, Python with MongoDB Database/model_building/main.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template 2 | import os 3 | from pymongo import MongoClient 4 | 5 | MONGODB_URI = 'mongodb+srv://himanshu:him12345@cluster0.z9357pa.mongodb.net/?retryWrites=true&w=majority' 6 | 7 | client = MongoClient(MONGODB_URI) 8 | 9 | # create a database 10 | 11 | # db = client.python_workshop 12 | 13 | # create a collection and insert document 14 | # db.students.insert_one({'name': 'Abhinav','Country':'India', 'age': 20}) 15 | 16 | # multiple documents/rows 17 | # l = [ 18 | # {'name': 'Ravi','Country':'India', 'age': 20}, 19 | # {'name': 'Brian','Country':'India', 'age': 20}, 20 | # {'name': 'Vinod','Country':'India', 'age': 20} 21 | # ] 22 | 23 | # for i in l: 24 | # db.students.insert_one(i) 25 | 26 | # read values from database 27 | db = client.python_workshop 28 | # s = db.students.find_one({'name':'Abhinav'}) 29 | 30 | query = { 31 | 'country':'India' 32 | } 33 | 34 | s = db.students.find(query) 35 | print(type(s)) 36 | for i in s: 37 | print(i) 38 | 39 | # print(client.list_database_names()) 40 | 41 | app = Flask(__name__) 42 | 43 | if __name__ == '__main__': 44 | port = int(os.environ.get("PORT", 5000)) 45 | app.run(port=port) -------------------------------------------------------------------------------- /07_Building API, Python with MongoDB Database/model_building/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 |

Profile

10 |
11 |

Name:

12 |

13 | {{ n }} 14 |

15 | 16 | -------------------------------------------------------------------------------- /08_Statistics with NumPy/.ipynb_checkpoints/8_NumPy-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "9df7c7c5", 6 | "metadata": {}, 7 | "source": [ 8 | "# NumPy\n", 9 | "\n", 10 | "Numeric Python\n", 11 | "\n", 12 | "n-D\n", 13 | "\n", 14 | "# Creating a Vector" 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": 1, 20 | "id": "dfce8f2e", 21 | "metadata": {}, 22 | "outputs": [ 23 | { 24 | "name": "stdout", 25 | "output_type": "stream", 26 | "text": [ 27 | "Requirement already satisfied: numpy in c:\\users\\himan\\anaconda3\\lib\\site-packages (1.21.5)\n" 28 | ] 29 | } 30 | ], 31 | "source": [ 32 | "!pip install numpy" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 2, 38 | "id": "bd29a4ae", 39 | "metadata": {}, 40 | "outputs": [ 41 | { 42 | "name": "stdout", 43 | "output_type": "stream", 44 | "text": [ 45 | "[1 2 3]\n" 46 | ] 47 | } 48 | ], 49 | "source": [ 50 | "import numpy as np\n", 51 | "\n", 52 | "v = np.array([1,2,3])\n", 53 | "\n", 54 | "print(v)" 55 | ] 56 | }, 57 | { 58 | "cell_type": "code", 59 | "execution_count": 3, 60 | "id": "137fe6ad", 61 | "metadata": {}, 62 | "outputs": [ 63 | { 64 | "name": "stdout", 65 | "output_type": "stream", 66 | "text": [ 67 | "\n" 68 | ] 69 | } 70 | ], 71 | "source": [ 72 | "print(type(v))" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": 4, 78 | "id": "bc9cd178", 79 | "metadata": {}, 80 | "outputs": [ 81 | { 82 | "name": "stdout", 83 | "output_type": "stream", 84 | "text": [ 85 | "[[1]\n", 86 | " [2]\n", 87 | " [3]]\n" 88 | ] 89 | } 90 | ], 91 | "source": [ 92 | "v = np.array([[1],[2],[3]])\n", 93 | "\n", 94 | "print(v)" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "execution_count": null, 100 | "id": "3faf191a", 101 | "metadata": {}, 102 | "outputs": [], 103 | "source": [ 104 | "0th dimension -> .\n", 105 | "1th dimension -> .________. #number line\n", 106 | "2nd D -> ._____|____.\n", 107 | "3rd D -> .____|____.\n", 108 | " /\n", 109 | "4th D" 110 | ] 111 | }, 112 | { 113 | "cell_type": "markdown", 114 | "id": "78474f99", 115 | "metadata": {}, 116 | "source": [ 117 | "# Creating a Matrix" 118 | ] 119 | }, 120 | { 121 | "cell_type": "code", 122 | "execution_count": 5, 123 | "id": "83b598ca", 124 | "metadata": {}, 125 | "outputs": [ 126 | { 127 | "name": "stdout", 128 | "output_type": "stream", 129 | "text": [ 130 | "[[1 2 3]\n", 131 | " [4 5 6]\n", 132 | " [7 8 9]]\n" 133 | ] 134 | } 135 | ], 136 | "source": [ 137 | "matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 138 | "\n", 139 | "print(matrix)" 140 | ] 141 | }, 142 | { 143 | "cell_type": "code", 144 | "execution_count": 6, 145 | "id": "1a8b45ab", 146 | "metadata": {}, 147 | "outputs": [ 148 | { 149 | "name": "stdout", 150 | "output_type": "stream", 151 | "text": [ 152 | "1\n" 153 | ] 154 | } 155 | ], 156 | "source": [ 157 | "print(matrix[0][0])" 158 | ] 159 | }, 160 | { 161 | "cell_type": "markdown", 162 | "id": "8374032b", 163 | "metadata": {}, 164 | "source": [ 165 | "# Selecting Elements" 166 | ] 167 | }, 168 | { 169 | "cell_type": "code", 170 | "execution_count": 7, 171 | "id": "e30482be", 172 | "metadata": {}, 173 | "outputs": [ 174 | { 175 | "name": "stdout", 176 | "output_type": "stream", 177 | "text": [ 178 | "[[1 2 3]\n", 179 | " [4 5 6]\n", 180 | " [7 8 9]]\n" 181 | ] 182 | } 183 | ], 184 | "source": [ 185 | "matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 186 | "\n", 187 | "print(matrix)" 188 | ] 189 | }, 190 | { 191 | "cell_type": "code", 192 | "execution_count": 8, 193 | "id": "440fdb04", 194 | "metadata": {}, 195 | "outputs": [ 196 | { 197 | "data": { 198 | "text/plain": [ 199 | "array([[1, 2, 3],\n", 200 | " [4, 5, 6],\n", 201 | " [7, 8, 9]])" 202 | ] 203 | }, 204 | "execution_count": 8, 205 | "metadata": {}, 206 | "output_type": "execute_result" 207 | } 208 | ], 209 | "source": [ 210 | "matrix[:]" 211 | ] 212 | }, 213 | { 214 | "cell_type": "code", 215 | "execution_count": 9, 216 | "id": "06e3998b", 217 | "metadata": {}, 218 | "outputs": [ 219 | { 220 | "data": { 221 | "text/plain": [ 222 | "array([[7, 8, 9]])" 223 | ] 224 | }, 225 | "execution_count": 9, 226 | "metadata": {}, 227 | "output_type": "execute_result" 228 | } 229 | ], 230 | "source": [ 231 | "matrix[2:5]" 232 | ] 233 | }, 234 | { 235 | "cell_type": "code", 236 | "execution_count": 10, 237 | "id": "00b90ae9", 238 | "metadata": {}, 239 | "outputs": [ 240 | { 241 | "data": { 242 | "text/plain": [ 243 | "array([[4, 5, 6],\n", 244 | " [7, 8, 9]])" 245 | ] 246 | }, 247 | "execution_count": 10, 248 | "metadata": {}, 249 | "output_type": "execute_result" 250 | } 251 | ], 252 | "source": [ 253 | "matrix[1:]" 254 | ] 255 | }, 256 | { 257 | "cell_type": "code", 258 | "execution_count": 11, 259 | "id": "54bb312e", 260 | "metadata": {}, 261 | "outputs": [ 262 | { 263 | "data": { 264 | "text/plain": [ 265 | "1" 266 | ] 267 | }, 268 | "execution_count": 11, 269 | "metadata": {}, 270 | "output_type": "execute_result" 271 | } 272 | ], 273 | "source": [ 274 | "matrix[0,0]" 275 | ] 276 | }, 277 | { 278 | "cell_type": "code", 279 | "execution_count": 12, 280 | "id": "1142b4b3", 281 | "metadata": {}, 282 | "outputs": [ 283 | { 284 | "data": { 285 | "text/plain": [ 286 | "5" 287 | ] 288 | }, 289 | "execution_count": 12, 290 | "metadata": {}, 291 | "output_type": "execute_result" 292 | } 293 | ], 294 | "source": [ 295 | "matrix[1,1]" 296 | ] 297 | }, 298 | { 299 | "cell_type": "code", 300 | "execution_count": null, 301 | "id": "ad6268e5", 302 | "metadata": {}, 303 | "outputs": [], 304 | "source": [ 305 | "00 01 02\n", 306 | "10 11 12\n", 307 | "20 21 22" 308 | ] 309 | }, 310 | { 311 | "cell_type": "code", 312 | "execution_count": 13, 313 | "id": "c7488017", 314 | "metadata": {}, 315 | "outputs": [ 316 | { 317 | "data": { 318 | "text/plain": [ 319 | "array([[1, 2, 3],\n", 320 | " [4, 5, 6],\n", 321 | " [7, 8, 9]])" 322 | ] 323 | }, 324 | "execution_count": 13, 325 | "metadata": {}, 326 | "output_type": "execute_result" 327 | } 328 | ], 329 | "source": [ 330 | "matrix" 331 | ] 332 | }, 333 | { 334 | "cell_type": "code", 335 | "execution_count": 14, 336 | "id": "66f5eab3", 337 | "metadata": {}, 338 | "outputs": [ 339 | { 340 | "data": { 341 | "text/plain": [ 342 | "array([[1, 2],\n", 343 | " [4, 5],\n", 344 | " [7, 8]])" 345 | ] 346 | }, 347 | "execution_count": 14, 348 | "metadata": {}, 349 | "output_type": "execute_result" 350 | } 351 | ], 352 | "source": [ 353 | "matrix[:3,:2]" 354 | ] 355 | }, 356 | { 357 | "cell_type": "code", 358 | "execution_count": 15, 359 | "id": "5202668c", 360 | "metadata": {}, 361 | "outputs": [ 362 | { 363 | "data": { 364 | "text/plain": [ 365 | "array([[2],\n", 366 | " [5],\n", 367 | " [8]])" 368 | ] 369 | }, 370 | "execution_count": 15, 371 | "metadata": {}, 372 | "output_type": "execute_result" 373 | } 374 | ], 375 | "source": [ 376 | "matrix[:,1:2]" 377 | ] 378 | }, 379 | { 380 | "cell_type": "markdown", 381 | "id": "9b0a2c7c", 382 | "metadata": {}, 383 | "source": [ 384 | "# Describing a Matrix" 385 | ] 386 | }, 387 | { 388 | "cell_type": "code", 389 | "execution_count": 16, 390 | "id": "eac0070a", 391 | "metadata": {}, 392 | "outputs": [ 393 | { 394 | "name": "stdout", 395 | "output_type": "stream", 396 | "text": [ 397 | "[[1 2 3]\n", 398 | " [4 5 6]\n", 399 | " [7 8 9]]\n" 400 | ] 401 | } 402 | ], 403 | "source": [ 404 | "matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 405 | "\n", 406 | "print(matrix)" 407 | ] 408 | }, 409 | { 410 | "cell_type": "code", 411 | "execution_count": 17, 412 | "id": "684e3242", 413 | "metadata": {}, 414 | "outputs": [ 415 | { 416 | "data": { 417 | "text/plain": [ 418 | "(3, 3)" 419 | ] 420 | }, 421 | "execution_count": 17, 422 | "metadata": {}, 423 | "output_type": "execute_result" 424 | } 425 | ], 426 | "source": [ 427 | "matrix.shape" 428 | ] 429 | }, 430 | { 431 | "cell_type": "code", 432 | "execution_count": 18, 433 | "id": "f689c6f3", 434 | "metadata": {}, 435 | "outputs": [ 436 | { 437 | "data": { 438 | "text/plain": [ 439 | "2" 440 | ] 441 | }, 442 | "execution_count": 18, 443 | "metadata": {}, 444 | "output_type": "execute_result" 445 | } 446 | ], 447 | "source": [ 448 | "matrix.ndim" 449 | ] 450 | }, 451 | { 452 | "cell_type": "code", 453 | "execution_count": 19, 454 | "id": "39153ea1", 455 | "metadata": {}, 456 | "outputs": [ 457 | { 458 | "data": { 459 | "text/plain": [ 460 | "int" 461 | ] 462 | }, 463 | "execution_count": 19, 464 | "metadata": {}, 465 | "output_type": "execute_result" 466 | } 467 | ], 468 | "source": [ 469 | "type(matrix.ndim)" 470 | ] 471 | }, 472 | { 473 | "cell_type": "code", 474 | "execution_count": 20, 475 | "id": "b81f1253", 476 | "metadata": {}, 477 | "outputs": [ 478 | { 479 | "data": { 480 | "text/plain": [ 481 | "9" 482 | ] 483 | }, 484 | "execution_count": 20, 485 | "metadata": {}, 486 | "output_type": "execute_result" 487 | } 488 | ], 489 | "source": [ 490 | "matrix.size" 491 | ] 492 | }, 493 | { 494 | "cell_type": "markdown", 495 | "id": "6d235c74", 496 | "metadata": {}, 497 | "source": [ 498 | "# Finding max and min values" 499 | ] 500 | }, 501 | { 502 | "cell_type": "code", 503 | "execution_count": 21, 504 | "id": "67140256", 505 | "metadata": {}, 506 | "outputs": [ 507 | { 508 | "name": "stdout", 509 | "output_type": "stream", 510 | "text": [ 511 | "[[1 2 3]\n", 512 | " [4 5 6]\n", 513 | " [7 8 9]]\n" 514 | ] 515 | } 516 | ], 517 | "source": [ 518 | "matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 519 | "\n", 520 | "print(matrix)" 521 | ] 522 | }, 523 | { 524 | "cell_type": "code", 525 | "execution_count": 22, 526 | "id": "bb285e25", 527 | "metadata": {}, 528 | "outputs": [ 529 | { 530 | "name": "stdout", 531 | "output_type": "stream", 532 | "text": [ 533 | "9\n" 534 | ] 535 | } 536 | ], 537 | "source": [ 538 | "print(np.max(matrix))" 539 | ] 540 | }, 541 | { 542 | "cell_type": "code", 543 | "execution_count": 23, 544 | "id": "875e3609", 545 | "metadata": {}, 546 | "outputs": [ 547 | { 548 | "name": "stdout", 549 | "output_type": "stream", 550 | "text": [ 551 | "1\n" 552 | ] 553 | } 554 | ], 555 | "source": [ 556 | "print(np.min(matrix))" 557 | ] 558 | }, 559 | { 560 | "cell_type": "code", 561 | "execution_count": 24, 562 | "id": "b5204e17", 563 | "metadata": {}, 564 | "outputs": [ 565 | { 566 | "name": "stdout", 567 | "output_type": "stream", 568 | "text": [ 569 | "[7 8 9]\n" 570 | ] 571 | } 572 | ], 573 | "source": [ 574 | "print(np.max(matrix, axis=0)) # columns" 575 | ] 576 | }, 577 | { 578 | "cell_type": "code", 579 | "execution_count": 25, 580 | "id": "8c768049", 581 | "metadata": {}, 582 | "outputs": [ 583 | { 584 | "name": "stdout", 585 | "output_type": "stream", 586 | "text": [ 587 | "[3 6 9]\n" 588 | ] 589 | } 590 | ], 591 | "source": [ 592 | "print(np.max(matrix, axis=1)) # rows" 593 | ] 594 | }, 595 | { 596 | "cell_type": "code", 597 | "execution_count": 27, 598 | "id": "68a53e23", 599 | "metadata": { 600 | "scrolled": false 601 | }, 602 | "outputs": [], 603 | "source": [ 604 | "# help(np.max)" 605 | ] 606 | }, 607 | { 608 | "cell_type": "markdown", 609 | "id": "6ceca5ed", 610 | "metadata": {}, 611 | "source": [ 612 | "# Mean, Variance and Standard Deviation" 613 | ] 614 | }, 615 | { 616 | "cell_type": "code", 617 | "execution_count": 49, 618 | "id": "ee2c1f84", 619 | "metadata": {}, 620 | "outputs": [ 621 | { 622 | "name": "stdout", 623 | "output_type": "stream", 624 | "text": [ 625 | "[[ 1 2 1]\n", 626 | " [ 1 1 1]\n", 627 | " [ 1 1 100]]\n" 628 | ] 629 | } 630 | ], 631 | "source": [ 632 | "matrix = np.array([[1,2,1],[1,1,1],[1,1,100]])\n", 633 | "\n", 634 | "print(matrix)" 635 | ] 636 | }, 637 | { 638 | "cell_type": "code", 639 | "execution_count": 44, 640 | "id": "17d8439f", 641 | "metadata": {}, 642 | "outputs": [ 643 | { 644 | "name": "stdout", 645 | "output_type": "stream", 646 | "text": [ 647 | "1.1111111111111112\n" 648 | ] 649 | } 650 | ], 651 | "source": [ 652 | "print(np.mean(matrix)) # 45/9 = 5.0" 653 | ] 654 | }, 655 | { 656 | "cell_type": "code", 657 | "execution_count": 45, 658 | "id": "dcff8b75", 659 | "metadata": {}, 660 | "outputs": [ 661 | { 662 | "name": "stdout", 663 | "output_type": "stream", 664 | "text": [ 665 | "1.0\n" 666 | ] 667 | } 668 | ], 669 | "source": [ 670 | "print(np.median(matrix))" 671 | ] 672 | }, 673 | { 674 | "cell_type": "code", 675 | "execution_count": 46, 676 | "id": "333dcc47", 677 | "metadata": {}, 678 | "outputs": [ 679 | { 680 | "name": "stdout", 681 | "output_type": "stream", 682 | "text": [ 683 | "0.3142696805273545\n" 684 | ] 685 | } 686 | ], 687 | "source": [ 688 | "print(np.std(matrix))" 689 | ] 690 | }, 691 | { 692 | "cell_type": "code", 693 | "execution_count": 47, 694 | "id": "6459a5ef", 695 | "metadata": {}, 696 | "outputs": [ 697 | { 698 | "name": "stdout", 699 | "output_type": "stream", 700 | "text": [ 701 | "0.09876543209876544\n" 702 | ] 703 | } 704 | ], 705 | "source": [ 706 | "print(np.var(matrix))" 707 | ] 708 | }, 709 | { 710 | "cell_type": "code", 711 | "execution_count": 50, 712 | "id": "830ac7e0", 713 | "metadata": {}, 714 | "outputs": [ 715 | { 716 | "data": { 717 | "text/plain": [ 718 | "99" 719 | ] 720 | }, 721 | "execution_count": 50, 722 | "metadata": {}, 723 | "output_type": "execute_result" 724 | } 725 | ], 726 | "source": [ 727 | "np.max(matrix) - np.min(matrix)" 728 | ] 729 | }, 730 | { 731 | "cell_type": "code", 732 | "execution_count": null, 733 | "id": "8ef51664", 734 | "metadata": {}, 735 | "outputs": [], 736 | "source": [ 737 | "# IQR" 738 | ] 739 | }, 740 | { 741 | "cell_type": "markdown", 742 | "id": "5c352ebc", 743 | "metadata": {}, 744 | "source": [ 745 | "# Reshaping Arrays" 746 | ] 747 | }, 748 | { 749 | "cell_type": "code", 750 | "execution_count": 51, 751 | "id": "6891a6a9", 752 | "metadata": {}, 753 | "outputs": [ 754 | { 755 | "name": "stdout", 756 | "output_type": "stream", 757 | "text": [ 758 | "[[1 2 3]\n", 759 | " [4 5 6]\n", 760 | " [7 8 9]]\n" 761 | ] 762 | } 763 | ], 764 | "source": [ 765 | "matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 766 | "\n", 767 | "print(matrix)" 768 | ] 769 | }, 770 | { 771 | "cell_type": "code", 772 | "execution_count": 52, 773 | "id": "1f29696d", 774 | "metadata": {}, 775 | "outputs": [ 776 | { 777 | "name": "stdout", 778 | "output_type": "stream", 779 | "text": [ 780 | "[[1]\n", 781 | " [2]\n", 782 | " [3]\n", 783 | " [4]\n", 784 | " [5]\n", 785 | " [6]\n", 786 | " [7]\n", 787 | " [8]\n", 788 | " [9]]\n" 789 | ] 790 | } 791 | ], 792 | "source": [ 793 | "print(matrix.reshape(9,1))" 794 | ] 795 | }, 796 | { 797 | "cell_type": "code", 798 | "execution_count": 53, 799 | "id": "0a016c5a", 800 | "metadata": {}, 801 | "outputs": [ 802 | { 803 | "ename": "ValueError", 804 | "evalue": "cannot reshape array of size 9 into shape (9,2)", 805 | "output_type": "error", 806 | "traceback": [ 807 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 808 | "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", 809 | "Input \u001b[1;32mIn [53]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mmatrix\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mreshape\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m9\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m)\u001b[49m)\n", 810 | "\u001b[1;31mValueError\u001b[0m: cannot reshape array of size 9 into shape (9,2)" 811 | ] 812 | } 813 | ], 814 | "source": [ 815 | "print(matrix.reshape(9,2))" 816 | ] 817 | }, 818 | { 819 | "cell_type": "code", 820 | "execution_count": 54, 821 | "id": "7a6d5f3a", 822 | "metadata": {}, 823 | "outputs": [ 824 | { 825 | "ename": "ValueError", 826 | "evalue": "cannot reshape array of size 9 into shape (4,2)", 827 | "output_type": "error", 828 | "traceback": [ 829 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 830 | "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", 831 | "Input \u001b[1;32mIn [54]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mmatrix\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mreshape\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m4\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m)\u001b[49m)\n", 832 | "\u001b[1;31mValueError\u001b[0m: cannot reshape array of size 9 into shape (4,2)" 833 | ] 834 | } 835 | ], 836 | "source": [ 837 | "print(matrix.reshape(4,2))" 838 | ] 839 | }, 840 | { 841 | "cell_type": "code", 842 | "execution_count": 55, 843 | "id": "98237ddc", 844 | "metadata": {}, 845 | "outputs": [ 846 | { 847 | "name": "stdout", 848 | "output_type": "stream", 849 | "text": [ 850 | "[[1 2 3 4 5 6 7 8 9]]\n" 851 | ] 852 | } 853 | ], 854 | "source": [ 855 | "print(matrix.reshape(1,9))" 856 | ] 857 | }, 858 | { 859 | "cell_type": "code", 860 | "execution_count": 56, 861 | "id": "93f38794", 862 | "metadata": {}, 863 | "outputs": [ 864 | { 865 | "name": "stdout", 866 | "output_type": "stream", 867 | "text": [ 868 | "[1 2 3 4 5 6 7 8 9]\n" 869 | ] 870 | } 871 | ], 872 | "source": [ 873 | "print(matrix.reshape(9)) # 1-d array" 874 | ] 875 | }, 876 | { 877 | "cell_type": "code", 878 | "execution_count": 57, 879 | "id": "8e5265bb", 880 | "metadata": { 881 | "scrolled": true 882 | }, 883 | "outputs": [ 884 | { 885 | "name": "stdout", 886 | "output_type": "stream", 887 | "text": [ 888 | "[1 2 3 4 5 6 7 8 9]\n" 889 | ] 890 | } 891 | ], 892 | "source": [ 893 | "print(matrix.flatten())" 894 | ] 895 | }, 896 | { 897 | "cell_type": "markdown", 898 | "id": "48d3cfbe", 899 | "metadata": {}, 900 | "source": [ 901 | "# Transpose of Matrix" 902 | ] 903 | }, 904 | { 905 | "cell_type": "code", 906 | "execution_count": 58, 907 | "id": "e4fdb963", 908 | "metadata": {}, 909 | "outputs": [ 910 | { 911 | "name": "stdout", 912 | "output_type": "stream", 913 | "text": [ 914 | "[[1 2 3]\n", 915 | " [4 5 6]\n", 916 | " [7 8 9]]\n" 917 | ] 918 | } 919 | ], 920 | "source": [ 921 | "matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 922 | "\n", 923 | "print(matrix)" 924 | ] 925 | }, 926 | { 927 | "cell_type": "code", 928 | "execution_count": 59, 929 | "id": "fd1ca2d8", 930 | "metadata": {}, 931 | "outputs": [ 932 | { 933 | "name": "stdout", 934 | "output_type": "stream", 935 | "text": [ 936 | "[[1 4 7]\n", 937 | " [2 5 8]\n", 938 | " [3 6 9]]\n" 939 | ] 940 | } 941 | ], 942 | "source": [ 943 | "print(matrix.T)" 944 | ] 945 | }, 946 | { 947 | "cell_type": "markdown", 948 | "id": "f5e30f9c", 949 | "metadata": {}, 950 | "source": [ 951 | "# Determinanat and Rank" 952 | ] 953 | }, 954 | { 955 | "cell_type": "code", 956 | "execution_count": 60, 957 | "id": "9fc0a334", 958 | "metadata": {}, 959 | "outputs": [ 960 | { 961 | "name": "stdout", 962 | "output_type": "stream", 963 | "text": [ 964 | "[[1 2 3]\n", 965 | " [4 5 6]\n", 966 | " [7 8 9]]\n" 967 | ] 968 | } 969 | ], 970 | "source": [ 971 | "matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 972 | "\n", 973 | "print(matrix)" 974 | ] 975 | }, 976 | { 977 | "cell_type": "code", 978 | "execution_count": 61, 979 | "id": "accccd96", 980 | "metadata": {}, 981 | "outputs": [ 982 | { 983 | "name": "stdout", 984 | "output_type": "stream", 985 | "text": [ 986 | "-9.51619735392994e-16\n" 987 | ] 988 | } 989 | ], 990 | "source": [ 991 | "print(np.linalg.det(matrix))" 992 | ] 993 | }, 994 | { 995 | "cell_type": "code", 996 | "execution_count": 62, 997 | "id": "5b9cf313", 998 | "metadata": {}, 999 | "outputs": [ 1000 | { 1001 | "name": "stdout", 1002 | "output_type": "stream", 1003 | "text": [ 1004 | "2\n" 1005 | ] 1006 | } 1007 | ], 1008 | "source": [ 1009 | "print(np.linalg.matrix_rank(matrix))" 1010 | ] 1011 | }, 1012 | { 1013 | "cell_type": "markdown", 1014 | "id": "83056e4c", 1015 | "metadata": {}, 1016 | "source": [ 1017 | "# Diagonal" 1018 | ] 1019 | }, 1020 | { 1021 | "cell_type": "code", 1022 | "execution_count": 63, 1023 | "id": "acecc1ce", 1024 | "metadata": {}, 1025 | "outputs": [ 1026 | { 1027 | "name": "stdout", 1028 | "output_type": "stream", 1029 | "text": [ 1030 | "[[1 2 3]\n", 1031 | " [4 5 6]\n", 1032 | " [7 8 9]]\n" 1033 | ] 1034 | } 1035 | ], 1036 | "source": [ 1037 | "matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 1038 | "\n", 1039 | "print(matrix)" 1040 | ] 1041 | }, 1042 | { 1043 | "cell_type": "code", 1044 | "execution_count": 64, 1045 | "id": "dd50c93b", 1046 | "metadata": {}, 1047 | "outputs": [ 1048 | { 1049 | "name": "stdout", 1050 | "output_type": "stream", 1051 | "text": [ 1052 | "[1 5 9]\n" 1053 | ] 1054 | } 1055 | ], 1056 | "source": [ 1057 | "print(matrix.diagonal())" 1058 | ] 1059 | }, 1060 | { 1061 | "cell_type": "code", 1062 | "execution_count": 65, 1063 | "id": "4713d1dd", 1064 | "metadata": {}, 1065 | "outputs": [ 1066 | { 1067 | "name": "stdout", 1068 | "output_type": "stream", 1069 | "text": [ 1070 | "[2 6]\n" 1071 | ] 1072 | } 1073 | ], 1074 | "source": [ 1075 | "print(matrix.diagonal(offset = 1))" 1076 | ] 1077 | }, 1078 | { 1079 | "cell_type": "code", 1080 | "execution_count": 66, 1081 | "id": "fcb2e904", 1082 | "metadata": {}, 1083 | "outputs": [ 1084 | { 1085 | "name": "stdout", 1086 | "output_type": "stream", 1087 | "text": [ 1088 | "[3]\n" 1089 | ] 1090 | } 1091 | ], 1092 | "source": [ 1093 | "print(matrix.diagonal(offset = 2))" 1094 | ] 1095 | }, 1096 | { 1097 | "cell_type": "code", 1098 | "execution_count": 67, 1099 | "id": "07673daa", 1100 | "metadata": {}, 1101 | "outputs": [ 1102 | { 1103 | "name": "stdout", 1104 | "output_type": "stream", 1105 | "text": [ 1106 | "[4 8]\n" 1107 | ] 1108 | } 1109 | ], 1110 | "source": [ 1111 | "print(matrix.diagonal(offset = -1))" 1112 | ] 1113 | }, 1114 | { 1115 | "cell_type": "markdown", 1116 | "id": "eca35851", 1117 | "metadata": {}, 1118 | "source": [ 1119 | "# Dot Product" 1120 | ] 1121 | }, 1122 | { 1123 | "cell_type": "code", 1124 | "execution_count": 68, 1125 | "id": "e6d6acfb", 1126 | "metadata": {}, 1127 | "outputs": [ 1128 | { 1129 | "name": "stdout", 1130 | "output_type": "stream", 1131 | "text": [ 1132 | "[[1 2 3]\n", 1133 | " [4 5 6]\n", 1134 | " [7 8 9]]\n", 1135 | "[[1 2 3]\n", 1136 | " [4 5 6]\n", 1137 | " [7 8 9]]\n", 1138 | "[[ 30 36 42]\n", 1139 | " [ 66 81 96]\n", 1140 | " [102 126 150]]\n" 1141 | ] 1142 | } 1143 | ], 1144 | "source": [ 1145 | "matrix1 = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 1146 | "\n", 1147 | "matrix2 = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 1148 | "\n", 1149 | "print(matrix1)\n", 1150 | "print(matrix2)\n", 1151 | "\n", 1152 | "print(np.dot(matrix1,matrix2))" 1153 | ] 1154 | }, 1155 | { 1156 | "cell_type": "code", 1157 | "execution_count": 69, 1158 | "id": "7d12bcbb", 1159 | "metadata": {}, 1160 | "outputs": [ 1161 | { 1162 | "data": { 1163 | "text/plain": [ 1164 | "array([[ 1, 4, 9],\n", 1165 | " [16, 25, 36],\n", 1166 | " [49, 64, 81]])" 1167 | ] 1168 | }, 1169 | "execution_count": 69, 1170 | "metadata": {}, 1171 | "output_type": "execute_result" 1172 | } 1173 | ], 1174 | "source": [ 1175 | "matrix1 * matrix2" 1176 | ] 1177 | }, 1178 | { 1179 | "cell_type": "code", 1180 | "execution_count": 71, 1181 | "id": "26291fda", 1182 | "metadata": {}, 1183 | "outputs": [ 1184 | { 1185 | "data": { 1186 | "text/plain": [ 1187 | "array([[ 30, 36, 42],\n", 1188 | " [ 66, 81, 96],\n", 1189 | " [102, 126, 150]])" 1190 | ] 1191 | }, 1192 | "execution_count": 71, 1193 | "metadata": {}, 1194 | "output_type": "execute_result" 1195 | } 1196 | ], 1197 | "source": [ 1198 | "matrix1 @ matrix2 # dot product" 1199 | ] 1200 | }, 1201 | { 1202 | "cell_type": "markdown", 1203 | "id": "8fb97734", 1204 | "metadata": {}, 1205 | "source": [ 1206 | "# Random Values" 1207 | ] 1208 | }, 1209 | { 1210 | "cell_type": "code", 1211 | "execution_count": 82, 1212 | "id": "d29b5ce0", 1213 | "metadata": {}, 1214 | "outputs": [ 1215 | { 1216 | "name": "stdout", 1217 | "output_type": "stream", 1218 | "text": [ 1219 | "[9 4 0]\n" 1220 | ] 1221 | } 1222 | ], 1223 | "source": [ 1224 | "np.random.seed(10)\n", 1225 | "\n", 1226 | "print(np.random.randint(0,11,3))" 1227 | ] 1228 | }, 1229 | { 1230 | "cell_type": "code", 1231 | "execution_count": 85, 1232 | "id": "b99f3a54", 1233 | "metadata": {}, 1234 | "outputs": [ 1235 | { 1236 | "name": "stdout", 1237 | "output_type": "stream", 1238 | "text": [ 1239 | "[-0.3642477 0.07756334 2.93133228]\n" 1240 | ] 1241 | } 1242 | ], 1243 | "source": [ 1244 | "print(np.random.normal(1.0,2.0,3)) # normal distribution of data\n", 1245 | "# mean, std, number of data points" 1246 | ] 1247 | }, 1248 | { 1249 | "cell_type": "code", 1250 | "execution_count": null, 1251 | "id": "c439ab17", 1252 | "metadata": {}, 1253 | "outputs": [], 1254 | "source": [] 1255 | } 1256 | ], 1257 | "metadata": { 1258 | "kernelspec": { 1259 | "display_name": "Python 3 (ipykernel)", 1260 | "language": "python", 1261 | "name": "python3" 1262 | }, 1263 | "language_info": { 1264 | "codemirror_mode": { 1265 | "name": "ipython", 1266 | "version": 3 1267 | }, 1268 | "file_extension": ".py", 1269 | "mimetype": "text/x-python", 1270 | "name": "python", 1271 | "nbconvert_exporter": "python", 1272 | "pygments_lexer": "ipython3", 1273 | "version": "3.9.12" 1274 | } 1275 | }, 1276 | "nbformat": 4, 1277 | "nbformat_minor": 5 1278 | } 1279 | -------------------------------------------------------------------------------- /08_Statistics with NumPy/8_NumPy.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "9df7c7c5", 6 | "metadata": {}, 7 | "source": [ 8 | "# NumPy\n", 9 | "\n", 10 | "Numeric Python\n", 11 | "\n", 12 | "n-D\n", 13 | "\n", 14 | "# Creating a Vector" 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": 1, 20 | "id": "dfce8f2e", 21 | "metadata": {}, 22 | "outputs": [ 23 | { 24 | "name": "stdout", 25 | "output_type": "stream", 26 | "text": [ 27 | "Requirement already satisfied: numpy in c:\\users\\himan\\anaconda3\\lib\\site-packages (1.21.5)\n" 28 | ] 29 | } 30 | ], 31 | "source": [ 32 | "!pip install numpy" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 2, 38 | "id": "bd29a4ae", 39 | "metadata": {}, 40 | "outputs": [ 41 | { 42 | "name": "stdout", 43 | "output_type": "stream", 44 | "text": [ 45 | "[1 2 3]\n" 46 | ] 47 | } 48 | ], 49 | "source": [ 50 | "import numpy as np\n", 51 | "\n", 52 | "v = np.array([1,2,3])\n", 53 | "\n", 54 | "print(v)" 55 | ] 56 | }, 57 | { 58 | "cell_type": "code", 59 | "execution_count": 3, 60 | "id": "137fe6ad", 61 | "metadata": {}, 62 | "outputs": [ 63 | { 64 | "name": "stdout", 65 | "output_type": "stream", 66 | "text": [ 67 | "\n" 68 | ] 69 | } 70 | ], 71 | "source": [ 72 | "print(type(v))" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": 4, 78 | "id": "bc9cd178", 79 | "metadata": {}, 80 | "outputs": [ 81 | { 82 | "name": "stdout", 83 | "output_type": "stream", 84 | "text": [ 85 | "[[1]\n", 86 | " [2]\n", 87 | " [3]]\n" 88 | ] 89 | } 90 | ], 91 | "source": [ 92 | "v = np.array([[1],[2],[3]])\n", 93 | "\n", 94 | "print(v)" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "execution_count": null, 100 | "id": "3faf191a", 101 | "metadata": {}, 102 | "outputs": [], 103 | "source": [ 104 | "0th dimension -> .\n", 105 | "1th dimension -> .________. #number line\n", 106 | "2nd D -> ._____|____.\n", 107 | "3rd D -> .____|____.\n", 108 | " /\n", 109 | "4th D" 110 | ] 111 | }, 112 | { 113 | "cell_type": "markdown", 114 | "id": "78474f99", 115 | "metadata": {}, 116 | "source": [ 117 | "# Creating a Matrix" 118 | ] 119 | }, 120 | { 121 | "cell_type": "code", 122 | "execution_count": 5, 123 | "id": "83b598ca", 124 | "metadata": {}, 125 | "outputs": [ 126 | { 127 | "name": "stdout", 128 | "output_type": "stream", 129 | "text": [ 130 | "[[1 2 3]\n", 131 | " [4 5 6]\n", 132 | " [7 8 9]]\n" 133 | ] 134 | } 135 | ], 136 | "source": [ 137 | "matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 138 | "\n", 139 | "print(matrix)" 140 | ] 141 | }, 142 | { 143 | "cell_type": "code", 144 | "execution_count": 6, 145 | "id": "1a8b45ab", 146 | "metadata": {}, 147 | "outputs": [ 148 | { 149 | "name": "stdout", 150 | "output_type": "stream", 151 | "text": [ 152 | "1\n" 153 | ] 154 | } 155 | ], 156 | "source": [ 157 | "print(matrix[0][0])" 158 | ] 159 | }, 160 | { 161 | "cell_type": "markdown", 162 | "id": "8374032b", 163 | "metadata": {}, 164 | "source": [ 165 | "# Selecting Elements" 166 | ] 167 | }, 168 | { 169 | "cell_type": "code", 170 | "execution_count": 7, 171 | "id": "e30482be", 172 | "metadata": {}, 173 | "outputs": [ 174 | { 175 | "name": "stdout", 176 | "output_type": "stream", 177 | "text": [ 178 | "[[1 2 3]\n", 179 | " [4 5 6]\n", 180 | " [7 8 9]]\n" 181 | ] 182 | } 183 | ], 184 | "source": [ 185 | "matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 186 | "\n", 187 | "print(matrix)" 188 | ] 189 | }, 190 | { 191 | "cell_type": "code", 192 | "execution_count": 8, 193 | "id": "440fdb04", 194 | "metadata": {}, 195 | "outputs": [ 196 | { 197 | "data": { 198 | "text/plain": [ 199 | "array([[1, 2, 3],\n", 200 | " [4, 5, 6],\n", 201 | " [7, 8, 9]])" 202 | ] 203 | }, 204 | "execution_count": 8, 205 | "metadata": {}, 206 | "output_type": "execute_result" 207 | } 208 | ], 209 | "source": [ 210 | "matrix[:]" 211 | ] 212 | }, 213 | { 214 | "cell_type": "code", 215 | "execution_count": 9, 216 | "id": "06e3998b", 217 | "metadata": {}, 218 | "outputs": [ 219 | { 220 | "data": { 221 | "text/plain": [ 222 | "array([[7, 8, 9]])" 223 | ] 224 | }, 225 | "execution_count": 9, 226 | "metadata": {}, 227 | "output_type": "execute_result" 228 | } 229 | ], 230 | "source": [ 231 | "matrix[2:5]" 232 | ] 233 | }, 234 | { 235 | "cell_type": "code", 236 | "execution_count": 10, 237 | "id": "00b90ae9", 238 | "metadata": {}, 239 | "outputs": [ 240 | { 241 | "data": { 242 | "text/plain": [ 243 | "array([[4, 5, 6],\n", 244 | " [7, 8, 9]])" 245 | ] 246 | }, 247 | "execution_count": 10, 248 | "metadata": {}, 249 | "output_type": "execute_result" 250 | } 251 | ], 252 | "source": [ 253 | "matrix[1:]" 254 | ] 255 | }, 256 | { 257 | "cell_type": "code", 258 | "execution_count": 11, 259 | "id": "54bb312e", 260 | "metadata": {}, 261 | "outputs": [ 262 | { 263 | "data": { 264 | "text/plain": [ 265 | "1" 266 | ] 267 | }, 268 | "execution_count": 11, 269 | "metadata": {}, 270 | "output_type": "execute_result" 271 | } 272 | ], 273 | "source": [ 274 | "matrix[0,0]" 275 | ] 276 | }, 277 | { 278 | "cell_type": "code", 279 | "execution_count": 12, 280 | "id": "1142b4b3", 281 | "metadata": {}, 282 | "outputs": [ 283 | { 284 | "data": { 285 | "text/plain": [ 286 | "5" 287 | ] 288 | }, 289 | "execution_count": 12, 290 | "metadata": {}, 291 | "output_type": "execute_result" 292 | } 293 | ], 294 | "source": [ 295 | "matrix[1,1]" 296 | ] 297 | }, 298 | { 299 | "cell_type": "code", 300 | "execution_count": null, 301 | "id": "ad6268e5", 302 | "metadata": {}, 303 | "outputs": [], 304 | "source": [ 305 | "00 01 02\n", 306 | "10 11 12\n", 307 | "20 21 22" 308 | ] 309 | }, 310 | { 311 | "cell_type": "code", 312 | "execution_count": 13, 313 | "id": "c7488017", 314 | "metadata": {}, 315 | "outputs": [ 316 | { 317 | "data": { 318 | "text/plain": [ 319 | "array([[1, 2, 3],\n", 320 | " [4, 5, 6],\n", 321 | " [7, 8, 9]])" 322 | ] 323 | }, 324 | "execution_count": 13, 325 | "metadata": {}, 326 | "output_type": "execute_result" 327 | } 328 | ], 329 | "source": [ 330 | "matrix" 331 | ] 332 | }, 333 | { 334 | "cell_type": "code", 335 | "execution_count": 14, 336 | "id": "66f5eab3", 337 | "metadata": {}, 338 | "outputs": [ 339 | { 340 | "data": { 341 | "text/plain": [ 342 | "array([[1, 2],\n", 343 | " [4, 5],\n", 344 | " [7, 8]])" 345 | ] 346 | }, 347 | "execution_count": 14, 348 | "metadata": {}, 349 | "output_type": "execute_result" 350 | } 351 | ], 352 | "source": [ 353 | "matrix[:3,:2]" 354 | ] 355 | }, 356 | { 357 | "cell_type": "code", 358 | "execution_count": 15, 359 | "id": "5202668c", 360 | "metadata": {}, 361 | "outputs": [ 362 | { 363 | "data": { 364 | "text/plain": [ 365 | "array([[2],\n", 366 | " [5],\n", 367 | " [8]])" 368 | ] 369 | }, 370 | "execution_count": 15, 371 | "metadata": {}, 372 | "output_type": "execute_result" 373 | } 374 | ], 375 | "source": [ 376 | "matrix[:,1:2]" 377 | ] 378 | }, 379 | { 380 | "cell_type": "markdown", 381 | "id": "9b0a2c7c", 382 | "metadata": {}, 383 | "source": [ 384 | "# Describing a Matrix" 385 | ] 386 | }, 387 | { 388 | "cell_type": "code", 389 | "execution_count": 16, 390 | "id": "eac0070a", 391 | "metadata": {}, 392 | "outputs": [ 393 | { 394 | "name": "stdout", 395 | "output_type": "stream", 396 | "text": [ 397 | "[[1 2 3]\n", 398 | " [4 5 6]\n", 399 | " [7 8 9]]\n" 400 | ] 401 | } 402 | ], 403 | "source": [ 404 | "matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 405 | "\n", 406 | "print(matrix)" 407 | ] 408 | }, 409 | { 410 | "cell_type": "code", 411 | "execution_count": 17, 412 | "id": "684e3242", 413 | "metadata": {}, 414 | "outputs": [ 415 | { 416 | "data": { 417 | "text/plain": [ 418 | "(3, 3)" 419 | ] 420 | }, 421 | "execution_count": 17, 422 | "metadata": {}, 423 | "output_type": "execute_result" 424 | } 425 | ], 426 | "source": [ 427 | "matrix.shape" 428 | ] 429 | }, 430 | { 431 | "cell_type": "code", 432 | "execution_count": 18, 433 | "id": "f689c6f3", 434 | "metadata": {}, 435 | "outputs": [ 436 | { 437 | "data": { 438 | "text/plain": [ 439 | "2" 440 | ] 441 | }, 442 | "execution_count": 18, 443 | "metadata": {}, 444 | "output_type": "execute_result" 445 | } 446 | ], 447 | "source": [ 448 | "matrix.ndim" 449 | ] 450 | }, 451 | { 452 | "cell_type": "code", 453 | "execution_count": 19, 454 | "id": "39153ea1", 455 | "metadata": {}, 456 | "outputs": [ 457 | { 458 | "data": { 459 | "text/plain": [ 460 | "int" 461 | ] 462 | }, 463 | "execution_count": 19, 464 | "metadata": {}, 465 | "output_type": "execute_result" 466 | } 467 | ], 468 | "source": [ 469 | "type(matrix.ndim)" 470 | ] 471 | }, 472 | { 473 | "cell_type": "code", 474 | "execution_count": 20, 475 | "id": "b81f1253", 476 | "metadata": {}, 477 | "outputs": [ 478 | { 479 | "data": { 480 | "text/plain": [ 481 | "9" 482 | ] 483 | }, 484 | "execution_count": 20, 485 | "metadata": {}, 486 | "output_type": "execute_result" 487 | } 488 | ], 489 | "source": [ 490 | "matrix.size" 491 | ] 492 | }, 493 | { 494 | "cell_type": "markdown", 495 | "id": "6d235c74", 496 | "metadata": {}, 497 | "source": [ 498 | "# Finding max and min values" 499 | ] 500 | }, 501 | { 502 | "cell_type": "code", 503 | "execution_count": 21, 504 | "id": "67140256", 505 | "metadata": {}, 506 | "outputs": [ 507 | { 508 | "name": "stdout", 509 | "output_type": "stream", 510 | "text": [ 511 | "[[1 2 3]\n", 512 | " [4 5 6]\n", 513 | " [7 8 9]]\n" 514 | ] 515 | } 516 | ], 517 | "source": [ 518 | "matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 519 | "\n", 520 | "print(matrix)" 521 | ] 522 | }, 523 | { 524 | "cell_type": "code", 525 | "execution_count": 22, 526 | "id": "bb285e25", 527 | "metadata": {}, 528 | "outputs": [ 529 | { 530 | "name": "stdout", 531 | "output_type": "stream", 532 | "text": [ 533 | "9\n" 534 | ] 535 | } 536 | ], 537 | "source": [ 538 | "print(np.max(matrix))" 539 | ] 540 | }, 541 | { 542 | "cell_type": "code", 543 | "execution_count": 23, 544 | "id": "875e3609", 545 | "metadata": {}, 546 | "outputs": [ 547 | { 548 | "name": "stdout", 549 | "output_type": "stream", 550 | "text": [ 551 | "1\n" 552 | ] 553 | } 554 | ], 555 | "source": [ 556 | "print(np.min(matrix))" 557 | ] 558 | }, 559 | { 560 | "cell_type": "code", 561 | "execution_count": 24, 562 | "id": "b5204e17", 563 | "metadata": {}, 564 | "outputs": [ 565 | { 566 | "name": "stdout", 567 | "output_type": "stream", 568 | "text": [ 569 | "[7 8 9]\n" 570 | ] 571 | } 572 | ], 573 | "source": [ 574 | "print(np.max(matrix, axis=0)) # columns" 575 | ] 576 | }, 577 | { 578 | "cell_type": "code", 579 | "execution_count": 25, 580 | "id": "8c768049", 581 | "metadata": {}, 582 | "outputs": [ 583 | { 584 | "name": "stdout", 585 | "output_type": "stream", 586 | "text": [ 587 | "[3 6 9]\n" 588 | ] 589 | } 590 | ], 591 | "source": [ 592 | "print(np.max(matrix, axis=1)) # rows" 593 | ] 594 | }, 595 | { 596 | "cell_type": "code", 597 | "execution_count": 27, 598 | "id": "68a53e23", 599 | "metadata": { 600 | "scrolled": false 601 | }, 602 | "outputs": [], 603 | "source": [ 604 | "# help(np.max)" 605 | ] 606 | }, 607 | { 608 | "cell_type": "markdown", 609 | "id": "6ceca5ed", 610 | "metadata": {}, 611 | "source": [ 612 | "# Mean, Variance and Standard Deviation" 613 | ] 614 | }, 615 | { 616 | "cell_type": "code", 617 | "execution_count": 49, 618 | "id": "ee2c1f84", 619 | "metadata": {}, 620 | "outputs": [ 621 | { 622 | "name": "stdout", 623 | "output_type": "stream", 624 | "text": [ 625 | "[[ 1 2 1]\n", 626 | " [ 1 1 1]\n", 627 | " [ 1 1 100]]\n" 628 | ] 629 | } 630 | ], 631 | "source": [ 632 | "matrix = np.array([[1,2,1],[1,1,1],[1,1,100]])\n", 633 | "\n", 634 | "print(matrix)" 635 | ] 636 | }, 637 | { 638 | "cell_type": "code", 639 | "execution_count": 44, 640 | "id": "17d8439f", 641 | "metadata": {}, 642 | "outputs": [ 643 | { 644 | "name": "stdout", 645 | "output_type": "stream", 646 | "text": [ 647 | "1.1111111111111112\n" 648 | ] 649 | } 650 | ], 651 | "source": [ 652 | "print(np.mean(matrix)) # 45/9 = 5.0" 653 | ] 654 | }, 655 | { 656 | "cell_type": "code", 657 | "execution_count": 45, 658 | "id": "dcff8b75", 659 | "metadata": {}, 660 | "outputs": [ 661 | { 662 | "name": "stdout", 663 | "output_type": "stream", 664 | "text": [ 665 | "1.0\n" 666 | ] 667 | } 668 | ], 669 | "source": [ 670 | "print(np.median(matrix))" 671 | ] 672 | }, 673 | { 674 | "cell_type": "code", 675 | "execution_count": 46, 676 | "id": "333dcc47", 677 | "metadata": {}, 678 | "outputs": [ 679 | { 680 | "name": "stdout", 681 | "output_type": "stream", 682 | "text": [ 683 | "0.3142696805273545\n" 684 | ] 685 | } 686 | ], 687 | "source": [ 688 | "print(np.std(matrix))" 689 | ] 690 | }, 691 | { 692 | "cell_type": "code", 693 | "execution_count": 47, 694 | "id": "6459a5ef", 695 | "metadata": {}, 696 | "outputs": [ 697 | { 698 | "name": "stdout", 699 | "output_type": "stream", 700 | "text": [ 701 | "0.09876543209876544\n" 702 | ] 703 | } 704 | ], 705 | "source": [ 706 | "print(np.var(matrix))" 707 | ] 708 | }, 709 | { 710 | "cell_type": "code", 711 | "execution_count": 50, 712 | "id": "830ac7e0", 713 | "metadata": {}, 714 | "outputs": [ 715 | { 716 | "data": { 717 | "text/plain": [ 718 | "99" 719 | ] 720 | }, 721 | "execution_count": 50, 722 | "metadata": {}, 723 | "output_type": "execute_result" 724 | } 725 | ], 726 | "source": [ 727 | "np.max(matrix) - np.min(matrix)" 728 | ] 729 | }, 730 | { 731 | "cell_type": "code", 732 | "execution_count": null, 733 | "id": "8ef51664", 734 | "metadata": {}, 735 | "outputs": [], 736 | "source": [ 737 | "# IQR" 738 | ] 739 | }, 740 | { 741 | "cell_type": "markdown", 742 | "id": "5c352ebc", 743 | "metadata": {}, 744 | "source": [ 745 | "# Reshaping Arrays" 746 | ] 747 | }, 748 | { 749 | "cell_type": "code", 750 | "execution_count": 51, 751 | "id": "6891a6a9", 752 | "metadata": {}, 753 | "outputs": [ 754 | { 755 | "name": "stdout", 756 | "output_type": "stream", 757 | "text": [ 758 | "[[1 2 3]\n", 759 | " [4 5 6]\n", 760 | " [7 8 9]]\n" 761 | ] 762 | } 763 | ], 764 | "source": [ 765 | "matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 766 | "\n", 767 | "print(matrix)" 768 | ] 769 | }, 770 | { 771 | "cell_type": "code", 772 | "execution_count": 52, 773 | "id": "1f29696d", 774 | "metadata": {}, 775 | "outputs": [ 776 | { 777 | "name": "stdout", 778 | "output_type": "stream", 779 | "text": [ 780 | "[[1]\n", 781 | " [2]\n", 782 | " [3]\n", 783 | " [4]\n", 784 | " [5]\n", 785 | " [6]\n", 786 | " [7]\n", 787 | " [8]\n", 788 | " [9]]\n" 789 | ] 790 | } 791 | ], 792 | "source": [ 793 | "print(matrix.reshape(9,1))" 794 | ] 795 | }, 796 | { 797 | "cell_type": "code", 798 | "execution_count": 53, 799 | "id": "0a016c5a", 800 | "metadata": {}, 801 | "outputs": [ 802 | { 803 | "ename": "ValueError", 804 | "evalue": "cannot reshape array of size 9 into shape (9,2)", 805 | "output_type": "error", 806 | "traceback": [ 807 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 808 | "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", 809 | "Input \u001b[1;32mIn [53]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mmatrix\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mreshape\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m9\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m)\u001b[49m)\n", 810 | "\u001b[1;31mValueError\u001b[0m: cannot reshape array of size 9 into shape (9,2)" 811 | ] 812 | } 813 | ], 814 | "source": [ 815 | "print(matrix.reshape(9,2))" 816 | ] 817 | }, 818 | { 819 | "cell_type": "code", 820 | "execution_count": 54, 821 | "id": "7a6d5f3a", 822 | "metadata": {}, 823 | "outputs": [ 824 | { 825 | "ename": "ValueError", 826 | "evalue": "cannot reshape array of size 9 into shape (4,2)", 827 | "output_type": "error", 828 | "traceback": [ 829 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", 830 | "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", 831 | "Input \u001b[1;32mIn [54]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mmatrix\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mreshape\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m4\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m)\u001b[49m)\n", 832 | "\u001b[1;31mValueError\u001b[0m: cannot reshape array of size 9 into shape (4,2)" 833 | ] 834 | } 835 | ], 836 | "source": [ 837 | "print(matrix.reshape(4,2))" 838 | ] 839 | }, 840 | { 841 | "cell_type": "code", 842 | "execution_count": 55, 843 | "id": "98237ddc", 844 | "metadata": {}, 845 | "outputs": [ 846 | { 847 | "name": "stdout", 848 | "output_type": "stream", 849 | "text": [ 850 | "[[1 2 3 4 5 6 7 8 9]]\n" 851 | ] 852 | } 853 | ], 854 | "source": [ 855 | "print(matrix.reshape(1,9))" 856 | ] 857 | }, 858 | { 859 | "cell_type": "code", 860 | "execution_count": 56, 861 | "id": "93f38794", 862 | "metadata": {}, 863 | "outputs": [ 864 | { 865 | "name": "stdout", 866 | "output_type": "stream", 867 | "text": [ 868 | "[1 2 3 4 5 6 7 8 9]\n" 869 | ] 870 | } 871 | ], 872 | "source": [ 873 | "print(matrix.reshape(9)) # 1-d array" 874 | ] 875 | }, 876 | { 877 | "cell_type": "code", 878 | "execution_count": 57, 879 | "id": "8e5265bb", 880 | "metadata": { 881 | "scrolled": true 882 | }, 883 | "outputs": [ 884 | { 885 | "name": "stdout", 886 | "output_type": "stream", 887 | "text": [ 888 | "[1 2 3 4 5 6 7 8 9]\n" 889 | ] 890 | } 891 | ], 892 | "source": [ 893 | "print(matrix.flatten())" 894 | ] 895 | }, 896 | { 897 | "cell_type": "markdown", 898 | "id": "48d3cfbe", 899 | "metadata": {}, 900 | "source": [ 901 | "# Transpose of Matrix" 902 | ] 903 | }, 904 | { 905 | "cell_type": "code", 906 | "execution_count": 58, 907 | "id": "e4fdb963", 908 | "metadata": {}, 909 | "outputs": [ 910 | { 911 | "name": "stdout", 912 | "output_type": "stream", 913 | "text": [ 914 | "[[1 2 3]\n", 915 | " [4 5 6]\n", 916 | " [7 8 9]]\n" 917 | ] 918 | } 919 | ], 920 | "source": [ 921 | "matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 922 | "\n", 923 | "print(matrix)" 924 | ] 925 | }, 926 | { 927 | "cell_type": "code", 928 | "execution_count": 59, 929 | "id": "fd1ca2d8", 930 | "metadata": {}, 931 | "outputs": [ 932 | { 933 | "name": "stdout", 934 | "output_type": "stream", 935 | "text": [ 936 | "[[1 4 7]\n", 937 | " [2 5 8]\n", 938 | " [3 6 9]]\n" 939 | ] 940 | } 941 | ], 942 | "source": [ 943 | "print(matrix.T)" 944 | ] 945 | }, 946 | { 947 | "cell_type": "markdown", 948 | "id": "f5e30f9c", 949 | "metadata": {}, 950 | "source": [ 951 | "# Determinanat and Rank" 952 | ] 953 | }, 954 | { 955 | "cell_type": "code", 956 | "execution_count": 60, 957 | "id": "9fc0a334", 958 | "metadata": {}, 959 | "outputs": [ 960 | { 961 | "name": "stdout", 962 | "output_type": "stream", 963 | "text": [ 964 | "[[1 2 3]\n", 965 | " [4 5 6]\n", 966 | " [7 8 9]]\n" 967 | ] 968 | } 969 | ], 970 | "source": [ 971 | "matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 972 | "\n", 973 | "print(matrix)" 974 | ] 975 | }, 976 | { 977 | "cell_type": "code", 978 | "execution_count": 61, 979 | "id": "accccd96", 980 | "metadata": {}, 981 | "outputs": [ 982 | { 983 | "name": "stdout", 984 | "output_type": "stream", 985 | "text": [ 986 | "-9.51619735392994e-16\n" 987 | ] 988 | } 989 | ], 990 | "source": [ 991 | "print(np.linalg.det(matrix))" 992 | ] 993 | }, 994 | { 995 | "cell_type": "code", 996 | "execution_count": 62, 997 | "id": "5b9cf313", 998 | "metadata": {}, 999 | "outputs": [ 1000 | { 1001 | "name": "stdout", 1002 | "output_type": "stream", 1003 | "text": [ 1004 | "2\n" 1005 | ] 1006 | } 1007 | ], 1008 | "source": [ 1009 | "print(np.linalg.matrix_rank(matrix))" 1010 | ] 1011 | }, 1012 | { 1013 | "cell_type": "markdown", 1014 | "id": "83056e4c", 1015 | "metadata": {}, 1016 | "source": [ 1017 | "# Diagonal" 1018 | ] 1019 | }, 1020 | { 1021 | "cell_type": "code", 1022 | "execution_count": 63, 1023 | "id": "acecc1ce", 1024 | "metadata": {}, 1025 | "outputs": [ 1026 | { 1027 | "name": "stdout", 1028 | "output_type": "stream", 1029 | "text": [ 1030 | "[[1 2 3]\n", 1031 | " [4 5 6]\n", 1032 | " [7 8 9]]\n" 1033 | ] 1034 | } 1035 | ], 1036 | "source": [ 1037 | "matrix = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 1038 | "\n", 1039 | "print(matrix)" 1040 | ] 1041 | }, 1042 | { 1043 | "cell_type": "code", 1044 | "execution_count": 64, 1045 | "id": "dd50c93b", 1046 | "metadata": {}, 1047 | "outputs": [ 1048 | { 1049 | "name": "stdout", 1050 | "output_type": "stream", 1051 | "text": [ 1052 | "[1 5 9]\n" 1053 | ] 1054 | } 1055 | ], 1056 | "source": [ 1057 | "print(matrix.diagonal())" 1058 | ] 1059 | }, 1060 | { 1061 | "cell_type": "code", 1062 | "execution_count": 65, 1063 | "id": "4713d1dd", 1064 | "metadata": {}, 1065 | "outputs": [ 1066 | { 1067 | "name": "stdout", 1068 | "output_type": "stream", 1069 | "text": [ 1070 | "[2 6]\n" 1071 | ] 1072 | } 1073 | ], 1074 | "source": [ 1075 | "print(matrix.diagonal(offset = 1))" 1076 | ] 1077 | }, 1078 | { 1079 | "cell_type": "code", 1080 | "execution_count": 66, 1081 | "id": "fcb2e904", 1082 | "metadata": {}, 1083 | "outputs": [ 1084 | { 1085 | "name": "stdout", 1086 | "output_type": "stream", 1087 | "text": [ 1088 | "[3]\n" 1089 | ] 1090 | } 1091 | ], 1092 | "source": [ 1093 | "print(matrix.diagonal(offset = 2))" 1094 | ] 1095 | }, 1096 | { 1097 | "cell_type": "code", 1098 | "execution_count": 67, 1099 | "id": "07673daa", 1100 | "metadata": {}, 1101 | "outputs": [ 1102 | { 1103 | "name": "stdout", 1104 | "output_type": "stream", 1105 | "text": [ 1106 | "[4 8]\n" 1107 | ] 1108 | } 1109 | ], 1110 | "source": [ 1111 | "print(matrix.diagonal(offset = -1))" 1112 | ] 1113 | }, 1114 | { 1115 | "cell_type": "markdown", 1116 | "id": "eca35851", 1117 | "metadata": {}, 1118 | "source": [ 1119 | "# Dot Product" 1120 | ] 1121 | }, 1122 | { 1123 | "cell_type": "code", 1124 | "execution_count": 68, 1125 | "id": "e6d6acfb", 1126 | "metadata": {}, 1127 | "outputs": [ 1128 | { 1129 | "name": "stdout", 1130 | "output_type": "stream", 1131 | "text": [ 1132 | "[[1 2 3]\n", 1133 | " [4 5 6]\n", 1134 | " [7 8 9]]\n", 1135 | "[[1 2 3]\n", 1136 | " [4 5 6]\n", 1137 | " [7 8 9]]\n", 1138 | "[[ 30 36 42]\n", 1139 | " [ 66 81 96]\n", 1140 | " [102 126 150]]\n" 1141 | ] 1142 | } 1143 | ], 1144 | "source": [ 1145 | "matrix1 = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 1146 | "\n", 1147 | "matrix2 = np.array([[1,2,3],[4,5,6],[7,8,9]])\n", 1148 | "\n", 1149 | "print(matrix1)\n", 1150 | "print(matrix2)\n", 1151 | "\n", 1152 | "print(np.dot(matrix1,matrix2))" 1153 | ] 1154 | }, 1155 | { 1156 | "cell_type": "code", 1157 | "execution_count": 69, 1158 | "id": "7d12bcbb", 1159 | "metadata": {}, 1160 | "outputs": [ 1161 | { 1162 | "data": { 1163 | "text/plain": [ 1164 | "array([[ 1, 4, 9],\n", 1165 | " [16, 25, 36],\n", 1166 | " [49, 64, 81]])" 1167 | ] 1168 | }, 1169 | "execution_count": 69, 1170 | "metadata": {}, 1171 | "output_type": "execute_result" 1172 | } 1173 | ], 1174 | "source": [ 1175 | "matrix1 * matrix2" 1176 | ] 1177 | }, 1178 | { 1179 | "cell_type": "code", 1180 | "execution_count": 71, 1181 | "id": "26291fda", 1182 | "metadata": {}, 1183 | "outputs": [ 1184 | { 1185 | "data": { 1186 | "text/plain": [ 1187 | "array([[ 30, 36, 42],\n", 1188 | " [ 66, 81, 96],\n", 1189 | " [102, 126, 150]])" 1190 | ] 1191 | }, 1192 | "execution_count": 71, 1193 | "metadata": {}, 1194 | "output_type": "execute_result" 1195 | } 1196 | ], 1197 | "source": [ 1198 | "matrix1 @ matrix2 # dot product" 1199 | ] 1200 | }, 1201 | { 1202 | "cell_type": "markdown", 1203 | "id": "8fb97734", 1204 | "metadata": {}, 1205 | "source": [ 1206 | "# Random Values" 1207 | ] 1208 | }, 1209 | { 1210 | "cell_type": "code", 1211 | "execution_count": 82, 1212 | "id": "d29b5ce0", 1213 | "metadata": {}, 1214 | "outputs": [ 1215 | { 1216 | "name": "stdout", 1217 | "output_type": "stream", 1218 | "text": [ 1219 | "[9 4 0]\n" 1220 | ] 1221 | } 1222 | ], 1223 | "source": [ 1224 | "np.random.seed(10)\n", 1225 | "\n", 1226 | "print(np.random.randint(0,11,3))" 1227 | ] 1228 | }, 1229 | { 1230 | "cell_type": "code", 1231 | "execution_count": 85, 1232 | "id": "b99f3a54", 1233 | "metadata": {}, 1234 | "outputs": [ 1235 | { 1236 | "name": "stdout", 1237 | "output_type": "stream", 1238 | "text": [ 1239 | "[-0.3642477 0.07756334 2.93133228]\n" 1240 | ] 1241 | } 1242 | ], 1243 | "source": [ 1244 | "print(np.random.normal(1.0,2.0,3)) # normal distribution of data\n", 1245 | "# mean, std, number of data points" 1246 | ] 1247 | }, 1248 | { 1249 | "cell_type": "code", 1250 | "execution_count": null, 1251 | "id": "c439ab17", 1252 | "metadata": {}, 1253 | "outputs": [], 1254 | "source": [] 1255 | } 1256 | ], 1257 | "metadata": { 1258 | "kernelspec": { 1259 | "display_name": "Python 3 (ipykernel)", 1260 | "language": "python", 1261 | "name": "python3" 1262 | }, 1263 | "language_info": { 1264 | "codemirror_mode": { 1265 | "name": "ipython", 1266 | "version": 3 1267 | }, 1268 | "file_extension": ".py", 1269 | "mimetype": "text/x-python", 1270 | "name": "python", 1271 | "nbconvert_exporter": "python", 1272 | "pygments_lexer": "ipython3", 1273 | "version": "3.9.12" 1274 | } 1275 | }, 1276 | "nbformat": 4, 1277 | "nbformat_minor": 5 1278 | } 1279 | -------------------------------------------------------------------------------- /08_Statistics with NumPy/NumPy Resources/NumPy Books/NumPy Cookbook, Second Edition.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/08_Statistics with NumPy/NumPy Resources/NumPy Books/NumPy Cookbook, Second Edition.pdf -------------------------------------------------------------------------------- /08_Statistics with NumPy/NumPy Resources/NumPy Cheat Sheet/Numpy_Python_Cheat_Sheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/08_Statistics with NumPy/NumPy Resources/NumPy Cheat Sheet/Numpy_Python_Cheat_Sheet.pdf -------------------------------------------------------------------------------- /08_Statistics with NumPy/NumPy Resources/NumPy Cheat Sheet/numpy-cheat-sheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/08_Statistics with NumPy/NumPy Resources/NumPy Cheat Sheet/numpy-cheat-sheet.pdf -------------------------------------------------------------------------------- /08_Statistics with NumPy/NumPy Resources/NumPy Cheat Sheet/numpy.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/08_Statistics with NumPy/NumPy Resources/NumPy Cheat Sheet/numpy.pdf -------------------------------------------------------------------------------- /08_Statistics with NumPy/NumPy Resources/NumPy Practice Questions/1-100 NumPy Exercises for Data Analysis.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/08_Statistics with NumPy/NumPy Resources/NumPy Practice Questions/1-100 NumPy Exercises for Data Analysis.pdf -------------------------------------------------------------------------------- /08_Statistics with NumPy/NumPy Resources/NumPy Practice Questions/2-NumPy Exercise 90 Questions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/08_Statistics with NumPy/NumPy Resources/NumPy Practice Questions/2-NumPy Exercise 90 Questions.pdf -------------------------------------------------------------------------------- /08_Statistics with NumPy/NumPy Resources/NumPy Practice Questions/3-Extras From Python to Numpy.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/08_Statistics with NumPy/NumPy Resources/NumPy Practice Questions/3-Extras From Python to Numpy.pdf -------------------------------------------------------------------------------- /08_Statistics with NumPy/NumPy Resources/NumPy Practice Questions/4-Advance Numpy Python.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/08_Statistics with NumPy/NumPy Resources/NumPy Practice Questions/4-Advance Numpy Python.pdf -------------------------------------------------------------------------------- /08_Statistics with NumPy/NumPy Resources/NumPy Reference or Documentation/NumPy Reference 1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/08_Statistics with NumPy/NumPy Resources/NumPy Reference or Documentation/NumPy Reference 1.pdf -------------------------------------------------------------------------------- /08_Statistics with NumPy/NumPy Resources/NumPy Reference or Documentation/NumPy Reference 2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/08_Statistics with NumPy/NumPy Resources/NumPy Reference or Documentation/NumPy Reference 2.pdf -------------------------------------------------------------------------------- /08_Statistics with NumPy/NumPy Resources/Reading Assignment-Beyond Numpy Arrays in Python.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/08_Statistics with NumPy/NumPy Resources/Reading Assignment-Beyond Numpy Arrays in Python.pdf -------------------------------------------------------------------------------- /08_Statistics with NumPy/NumPy Resources/Reading Assignment-NumPy project governance.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/08_Statistics with NumPy/NumPy Resources/Reading Assignment-NumPy project governance.pdf -------------------------------------------------------------------------------- /09_Data Analysis with Pandas/.ipynb_checkpoints/9_Pandas-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [], 3 | "metadata": {}, 4 | "nbformat": 4, 5 | "nbformat_minor": 5 6 | } 7 | -------------------------------------------------------------------------------- /09_Data Analysis with Pandas/Pandas Books/Learning pandas.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/09_Data Analysis with Pandas/Pandas Books/Learning pandas.pdf -------------------------------------------------------------------------------- /09_Data Analysis with Pandas/Pandas Books/Mastering Pandas.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/09_Data Analysis with Pandas/Pandas Books/Mastering Pandas.pdf -------------------------------------------------------------------------------- /09_Data Analysis with Pandas/nyc_weather.csv: -------------------------------------------------------------------------------- 1 | EST,Temperature,DewPoint,Humidity,Sea Level PressureIn,VisibilityMiles,WindSpeedMPH,PrecipitationIn,CloudCover,Events,WindDirDegrees 2 | 1/1/2016,38,23,52,30.03,10,8,0,5,,281 3 | 1/2/2016,36,18,46,30.02,10,7,0,3,,275 4 | 1/3/2016,40,21,47,29.86,10,8,0,1,,277 5 | 1/4/2016,25,9,44,30.05,10,9,0,3,,345 6 | 1/5/2016,20,-3,41,30.57,10,5,0,0,,333 7 | 1/6/2016,33,4,35,30.5,10,4,0,0,,259 8 | 1/7/2016,39,11,33,30.28,10,2,0,3,,293 9 | 1/8/2016,39,29,64,30.2,10,4,0,8,,79 10 | 1/9/2016,44,38,77,30.16,9,8,T,8,Rain,76 11 | 1/10/2016,50,46,71,29.59,4,,1.8,7,Rain,109 12 | 1/11/2016,33,8,37,29.92,10,,0,1,,289 13 | 1/12/2016,35,15,53,29.85,10,6,T,4,,235 14 | 1/13/2016,26,4,42,29.94,10,10,0,0,,284 15 | 1/14/2016,30,12,47,29.95,10,5,T,7,,266 16 | 1/15/2016,43,31,62,29.82,9,5,T,2,,101 17 | 1/16/2016,47,37,70,29.52,8,7,0.24,7,Rain,340 18 | 1/17/2016,36,23,66,29.78,8,6,0.05,6,Fog-Snow,345 19 | 1/18/2016,25,6,53,29.83,9,12,T,2,Snow,293 20 | 1/19/2016,22,3,42,30.03,10,11,0,1,,293 21 | 1/20/2016,32,15,49,30.13,10,6,0,2,,302 22 | 1/21/2016,31,11,45,30.15,10,6,0,1,,312 23 | 1/22/2016,26,6,41,30.21,9,,0.01,3,Snow,34 24 | 1/23/2016,26,21,78,29.77,1,16,2.31,8,Fog-Snow,42 25 | 1/24/2016,28,11,53,29.92,8,6,T,3,Snow,327 26 | 1/25/2016,34,18,54,30.25,10,3,0,2,,286 27 | 1/26/2016,43,29,56,30.03,10,7,0,2,,244 28 | 1/27/2016,41,22,45,30.03,10,7,T,3,Rain,311 29 | 1/28/2016,37,20,51,29.9,10,5,0,1,,234 30 | 1/29/2016,36,21,50,29.58,10,8,0,4,,298 31 | 1/30/2016,34,16,46,30.01,10,7,0,0,,257 32 | 1/31/2016,46,28,52,29.9,10,5,0,0,,241 33 | -------------------------------------------------------------------------------- /09_Data Analysis with Pandas/stock_data.csv: -------------------------------------------------------------------------------- 1 | tickers,eps,revenue,price,people 2 | GOOGL,27.82,87,845,larry page 3 | WMT,4.61,484,65,n.a. 4 | MSFT,-1,85,64,bill gates 5 | RIL ,not available,50,1023,mukesh ambani 6 | TATA,5.6,-1,n.a.,ratan tata 7 | -------------------------------------------------------------------------------- /09_Data Analysis with Pandas/stocks_weather.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/09_Data Analysis with Pandas/stocks_weather.xlsx -------------------------------------------------------------------------------- /09_Data Analysis with Pandas/weather_by_cities.csv: -------------------------------------------------------------------------------- 1 | day,city,temperature,windspeed,event 2 | 1/1/2017,new york,32,6,Rain 3 | 1/2/2017,new york,36,7,Sunny 4 | 1/3/2017,new york,28,12,Snow 5 | 1/4/2017,new york,33,7,Sunny 6 | 1/1/2017,mumbai,90,5,Sunny 7 | 1/2/2017,mumbai,85,12,Fog 8 | 1/3/2017,mumbai,87,15,Fog 9 | 1/4/2017,mumbai,92,5,Rain 10 | 1/1/2017,paris,45,20,Sunny 11 | 1/2/2017,paris,50,13,Cloudy 12 | 1/3/2017,paris,54,8,Cloudy 13 | 1/4/2017,paris,42,10,Cloudy 14 | -------------------------------------------------------------------------------- /09_Data Analysis with Pandas/weather_data.csv: -------------------------------------------------------------------------------- 1 | day,temperature,windspeed,event 2 | 1/1/2017,32,6,Rain 3 | 1/2/2017,35,7,Sunny 4 | 1/3/2017,28,2,Snow 5 | 1/4/2017,24,7,Snow 6 | 1/5/2017,32,4,Rain 7 | 1/6/2017,31,2,Sunny 8 | -------------------------------------------------------------------------------- /09_Data Analysis with Pandas/weather_data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/09_Data Analysis with Pandas/weather_data.xlsx -------------------------------------------------------------------------------- /09_Data Analysis with Pandas/weather_data2.csv: -------------------------------------------------------------------------------- 1 | day,temperature,windspeed,event 2 | 1/1/2017,32,6,Rain 3 | 1/4/2017,,9,Sunny 4 | 1/5/2017,28,,Snow 5 | 1/6/2017,,7, 6 | 1/7/2017,32,,Rain 7 | 1/8/2017,,,Sunny 8 | 1/9/2017,,, 9 | 1/10/2017,34,8,Cloudy 10 | 1/11/2017,40,12,Sunny 11 | -------------------------------------------------------------------------------- /09_Data Analysis with Pandas/weather_datamissing.csv: -------------------------------------------------------------------------------- 1 | day,temperature,windspeed,event 2 | 1/1/2017,32,6,Rain 3 | 1/2/2017,-99999,7,Sunny 4 | 1/3/2017,28,-99999,Snow 5 | 1/4/2017,-99999,7,0 6 | 1/5/2017,32,-99999,Rain 7 | 1/6/2017,31,2,Sunny 8 | 1/6/2017,34,5,0 9 | -------------------------------------------------------------------------------- /10_Data Visualization with Matplotlib/nyc_weather.csv: -------------------------------------------------------------------------------- 1 | EST,Temperature,DewPoint,Humidity,Sea Level PressureIn,VisibilityMiles,WindSpeedMPH,PrecipitationIn,CloudCover,Events,WindDirDegrees 2 | 1/1/2016,38,23,52,30.03,10,8,0,5,,281 3 | 1/2/2016,36,18,46,30.02,10,7,0,3,,275 4 | 1/3/2016,40,21,47,29.86,10,8,0,1,,277 5 | 1/4/2016,25,9,44,30.05,10,9,0,3,,345 6 | 1/5/2016,20,-3,41,30.57,10,5,0,0,,333 7 | 1/6/2016,33,4,35,30.5,10,4,0,0,,259 8 | 1/7/2016,39,11,33,30.28,10,2,0,3,,293 9 | 1/8/2016,39,29,64,30.2,10,4,0,8,,79 10 | 1/9/2016,44,38,77,30.16,9,8,T,8,Rain,76 11 | 1/10/2016,50,46,71,29.59,4,,1.8,7,Rain,109 12 | 1/11/2016,33,8,37,29.92,10,,0,1,,289 13 | 1/12/2016,35,15,53,29.85,10,6,T,4,,235 14 | 1/13/2016,26,4,42,29.94,10,10,0,0,,284 15 | 1/14/2016,30,12,47,29.95,10,5,T,7,,266 16 | 1/15/2016,43,31,62,29.82,9,5,T,2,,101 17 | 1/16/2016,47,37,70,29.52,8,7,0.24,7,Rain,340 18 | 1/17/2016,36,23,66,29.78,8,6,0.05,6,Fog-Snow,345 19 | 1/18/2016,25,6,53,29.83,9,12,T,2,Snow,293 20 | 1/19/2016,22,3,42,30.03,10,11,0,1,,293 21 | 1/20/2016,32,15,49,30.13,10,6,0,2,,302 22 | 1/21/2016,31,11,45,30.15,10,6,0,1,,312 23 | 1/22/2016,26,6,41,30.21,9,,0.01,3,Snow,34 24 | 1/23/2016,26,21,78,29.77,1,16,2.31,8,Fog-Snow,42 25 | 1/24/2016,28,11,53,29.92,8,6,T,3,Snow,327 26 | 1/25/2016,34,18,54,30.25,10,3,0,2,,286 27 | 1/26/2016,43,29,56,30.03,10,7,0,2,,244 28 | 1/27/2016,41,22,45,30.03,10,7,T,3,Rain,311 29 | 1/28/2016,37,20,51,29.9,10,5,0,1,,234 30 | 1/29/2016,36,21,50,29.58,10,8,0,4,,298 31 | 1/30/2016,34,16,46,30.01,10,7,0,0,,257 32 | 1/31/2016,46,28,52,29.9,10,5,0,0,,241 33 | -------------------------------------------------------------------------------- /10_Data Visualization with Matplotlib/stock_data.csv: -------------------------------------------------------------------------------- 1 | tickers,eps,revenue,price,people 2 | GOOGL,27.82,87,845,larry page 3 | WMT,4.61,484,65,n.a. 4 | MSFT,-1,85,64,bill gates 5 | RIL ,not available,50,1023,mukesh ambani 6 | TATA,5.6,-1,n.a.,ratan tata 7 | -------------------------------------------------------------------------------- /10_Data Visualization with Matplotlib/stocks_weather.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/10_Data Visualization with Matplotlib/stocks_weather.xlsx -------------------------------------------------------------------------------- /10_Data Visualization with Matplotlib/weather_by_cities.csv: -------------------------------------------------------------------------------- 1 | day,city,temperature,windspeed,event 2 | 1/1/2017,new york,32,6,Rain 3 | 1/2/2017,new york,36,7,Sunny 4 | 1/3/2017,new york,28,12,Snow 5 | 1/4/2017,new york,33,7,Sunny 6 | 1/1/2017,mumbai,90,5,Sunny 7 | 1/2/2017,mumbai,85,12,Fog 8 | 1/3/2017,mumbai,87,15,Fog 9 | 1/4/2017,mumbai,92,5,Rain 10 | 1/1/2017,paris,45,20,Sunny 11 | 1/2/2017,paris,50,13,Cloudy 12 | 1/3/2017,paris,54,8,Cloudy 13 | 1/4/2017,paris,42,10,Cloudy 14 | -------------------------------------------------------------------------------- /10_Data Visualization with Matplotlib/weather_data.csv: -------------------------------------------------------------------------------- 1 | day,temperature,windspeed,event 2 | 1/1/2017,32,6,Rain 3 | 1/2/2017,35,7,Sunny 4 | 1/3/2017,28,2,Snow 5 | 1/4/2017,24,7,Snow 6 | 1/5/2017,32,4,Rain 7 | 1/6/2017,31,2,Sunny 8 | -------------------------------------------------------------------------------- /10_Data Visualization with Matplotlib/weather_data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/10_Data Visualization with Matplotlib/weather_data.xlsx -------------------------------------------------------------------------------- /10_Data Visualization with Matplotlib/weather_data2.csv: -------------------------------------------------------------------------------- 1 | day,temperature,windspeed,event 2 | 1/1/2017,32,6,Rain 3 | 1/4/2017,,9,Sunny 4 | 1/5/2017,28,,Snow 5 | 1/6/2017,,7, 6 | 1/7/2017,32,,Rain 7 | 1/8/2017,,,Sunny 8 | 1/9/2017,,, 9 | 1/10/2017,34,8,Cloudy 10 | 1/11/2017,40,12,Sunny 11 | -------------------------------------------------------------------------------- /10_Data Visualization with Matplotlib/weather_datamissing.csv: -------------------------------------------------------------------------------- 1 | day,temperature,windspeed,event 2 | 1/1/2017,32,6,Rain 3 | 1/2/2017,-99999,7,Sunny 4 | 1/3/2017,28,-99999,Snow 5 | 1/4/2017,-99999,7,0 6 | 1/5/2017,32,-99999,Rain 7 | 1/6/2017,31,2,Sunny 8 | 1/6/2017,34,5,0 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python-For-Data-Professionals 2 | 3 | I created this Live course for Data Professionals so that they can learn Python in 12 days for starting their data journey. 4 | 5 | This roadmap is designed to get a good grip on python programming, logic building, solving algorithm-based questions, understanding of data analytics, working with pandas, professional practices, and API building. 6 | 7 | ![Python Header](https://github.com/hemansnation/Python-For-Data-Professionals/blob/main/images/header.png) 8 | 9 | # The only course you need to build a strong foundation of Python for your data journey. 10 | 11 | 12 | ### Key features of this workshop: 13 | 14 | - Live 12 Days Sessions (24 Hours in Total). 15 | - Lifetime access to recordings and resources. 16 | - Community support of like-minded data professionals. 17 | - You can get FREE access to future Live sessions on Python for lifetime learning. 18 | - Editable Notion template so that you can create your own notes in an organized manner. 19 | 20 | 21 | ## It is divided into 12 Chapters 👇 22 | 23 | 24 | 1 | While Loops, Lists, Strings
25 | 2 | For Loop, Dictionary, Tuples, Set
26 | 3 | Object-Oriented Programming
27 | 4 | Modules, Packages, and PIP
28 | 5 | Functions & Higher-Order Functions
29 | 6 | Virtual Environment, Flask, and Python Web Scrapping
30 | 7 | Building API, Python with MongoDB Database
31 | 8 | Statistics with NumPy
32 | 9 | Data Analysis with Pandas
33 | 10 | Data Visualization with Matplotlib
34 | 11 | Projects
35 | 12 | Resource collection, Interview Questions, What to do Next? How to approach Data Science.
36 | 37 | ![Notion Tempate](https://github.com/hemansnation/Python-For-Data-Professionals/blob/main/images/notion.gif) 38 | 39 | [Get the detailed Roadmap Here](https://www.notion.so/god-level-python/Python-for-Data-Professionals-12-Days-Live-Course-8e3717c428e64c2fbb58546b036d80de) 40 | 41 | 42 | 43 | ## Who can join? 44 | - You are working in the field of data. 45 | - If you are a professional and want to transition into data science, this can be your starting point. 46 | - Do you want to work on Python programming and logic building as a Data Analyst or Business Analyst? 47 | - Learn Python for technical rounds of Managers in tech companies. 48 | - You are a product manager and want to get into programming. 49 | - You are targeting the Machine Learning position for your job, you can start here. 50 | 51 | 52 | ## What you will gain? 53 | - You will know how to build Logic for Programming. 54 | - You will be confident in Python. 55 | - You will know how to work with data. 56 | - You will gain Hands-on experience working with data sets, including cleaning, transforming, and visualizing data. 57 | - You will get access to course materials, including lecture notes, code snippets, and exercise problems, as well as a community of like-minded professionals who are also taking the course. 58 | 59 | # Instructor 60 | 61 | ![Himanshu Ramchandani](https://github.com/hemansnation/Python-For-Data-Professionals/blob/main/images/instructorhimanshu.png) 62 | 63 | 64 | # Starting 4th February 2023 65 | # Registration Closed 66 | -------------------------------------------------------------------------------- /images/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/images/header.png -------------------------------------------------------------------------------- /images/instructorhimanshu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/images/instructorhimanshu.png -------------------------------------------------------------------------------- /images/notion.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemansnation/Python-For-Data-Professionals/39ac352ff007949fe88f1b8beedc5cb2514bb948/images/notion.gif --------------------------------------------------------------------------------