├── Exercises ├── exercise1_str_lists_tuples.ipynb ├── exercise2_condtionals_loops.ipynb └── exercise3_dictionaries_functions.ipynb ├── Notebooks ├── Numpy_fundamentals.ipynb ├── python_fundamentals_part-1.ipynb ├── python_fundamentals_part-2.ipynb ├── python_fundamentals_part-3.ipynb └── python_fundamentals_part_1.ipynb ├── README.md └── images ├── Group 86 (1).png └── apple_stock_eod_prices.csv /Exercises/exercise1_str_lists_tuples.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Python fundamentals Exercises (Expressions, Strings, Lists, Tuples)\n", 8 | "\n", 9 | "The notebook intends to help you practice these concepts. Attempt honestly.\n", 10 | "\n", 11 | "Instructions/Suggestions:\n", 12 | "1. Don't forget to copy the expression from the Question to code cell!\n", 13 | "2. You can use the python documentation anytime you want to learn about a new function or attribute." 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "## Q1: What is 84 / 12 + 2 * 2 ?" 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": 29, 26 | "metadata": {}, 27 | "outputs": [], 28 | "source": [ 29 | "# code and test below...\n", 30 | "\n" 31 | ] 32 | }, 33 | { 34 | "cell_type": "markdown", 35 | "metadata": {}, 36 | "source": [ 37 | "## Q2: What is the type of the answer variable in this expression:\n", 38 | "\n", 39 | "`answer = 12/4`" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": 30, 45 | "metadata": {}, 46 | "outputs": [], 47 | "source": [ 48 | "# code and test below...\n", 49 | "\n", 50 | "\n" 51 | ] 52 | }, 53 | { 54 | "cell_type": "markdown", 55 | "metadata": {}, 56 | "source": [ 57 | "## Q3: What is the value of num?\n", 58 | "\n", 59 | "```python\n", 60 | "num = 2\n", 61 | "num = 5*10\n", 62 | "```" 63 | ] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": 31, 68 | "metadata": {}, 69 | "outputs": [], 70 | "source": [ 71 | "# code and test below...\n", 72 | "\n" 73 | ] 74 | }, 75 | { 76 | "cell_type": "markdown", 77 | "metadata": {}, 78 | "source": [ 79 | "## Q4: What would this expression evaluate to?\n", 80 | "\n", 81 | "`'tom' + 1`" 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": 32, 87 | "metadata": {}, 88 | "outputs": [], 89 | "source": [ 90 | "# code and test below...\n", 91 | "\n" 92 | ] 93 | }, 94 | { 95 | "cell_type": "markdown", 96 | "metadata": {}, 97 | "source": [ 98 | "## Q5: What would this expression evaluate to?\n", 99 | "\n", 100 | "`'6' + '4'`" 101 | ] 102 | }, 103 | { 104 | "cell_type": "code", 105 | "execution_count": 33, 106 | "metadata": {}, 107 | "outputs": [], 108 | "source": [ 109 | "# code and test below...\n", 110 | "\n" 111 | ] 112 | }, 113 | { 114 | "cell_type": "markdown", 115 | "metadata": {}, 116 | "source": [ 117 | "## Q6: What would be the output of MyString[5:12] if?\n", 118 | "\n", 119 | "`MyString = \"Data Science with Harshit\"`" 120 | ] 121 | }, 122 | { 123 | "cell_type": "code", 124 | "execution_count": 34, 125 | "metadata": {}, 126 | "outputs": [], 127 | "source": [ 128 | "# code and test below...\n", 129 | "\n" 130 | ] 131 | }, 132 | { 133 | "cell_type": "markdown", 134 | "metadata": {}, 135 | "source": [ 136 | "## Q7: What would be the output of MyString[5:] if?\n", 137 | "\n", 138 | "`MyString = \"Data Science with Harshit\"`" 139 | ] 140 | }, 141 | { 142 | "cell_type": "code", 143 | "execution_count": 35, 144 | "metadata": {}, 145 | "outputs": [], 146 | "source": [ 147 | "# code and test below...\n", 148 | "\n" 149 | ] 150 | }, 151 | { 152 | "cell_type": "markdown", 153 | "metadata": {}, 154 | "source": [ 155 | "## Q8: What would be the output of MyString[5::2] if?\n", 156 | "\n", 157 | "`MyString = \"Data Science with Harshit\"`" 158 | ] 159 | }, 160 | { 161 | "cell_type": "code", 162 | "execution_count": 36, 163 | "metadata": {}, 164 | "outputs": [], 165 | "source": [ 166 | "# code and test below...\n", 167 | "\n" 168 | ] 169 | }, 170 | { 171 | "cell_type": "markdown", 172 | "metadata": {}, 173 | "source": [ 174 | "## Q9: Is there any 'go' in MyString if yes, at what index? \n", 175 | "\n", 176 | "`MyString = \"You should go to your home!\"`" 177 | ] 178 | }, 179 | { 180 | "cell_type": "code", 181 | "execution_count": 37, 182 | "metadata": {}, 183 | "outputs": [], 184 | "source": [ 185 | "# code and test below...\n", 186 | "\n" 187 | ] 188 | }, 189 | { 190 | "cell_type": "markdown", 191 | "metadata": {}, 192 | "source": [ 193 | "## Q10: Evaluate the following expression and convert it to string object?\n", 194 | "\n", 195 | "`18 + 19 * 11`" 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": 38, 201 | "metadata": {}, 202 | "outputs": [], 203 | "source": [ 204 | "# code and test below...\n", 205 | "\n" 206 | ] 207 | }, 208 | { 209 | "cell_type": "markdown", 210 | "metadata": {}, 211 | "source": [ 212 | "## Q11: Replace Harshit with your name in the statement below.\n", 213 | "\n", 214 | "`MyString = \"Data Science with Harshit\"`" 215 | ] 216 | }, 217 | { 218 | "cell_type": "code", 219 | "execution_count": 39, 220 | "metadata": {}, 221 | "outputs": [], 222 | "source": [ 223 | "# code and test below...\n", 224 | "\n" 225 | ] 226 | }, 227 | { 228 | "cell_type": "markdown", 229 | "metadata": {}, 230 | "source": [ 231 | "## Q12: Use the split() function to extract all the words of MyString in a list:\n", 232 | "\n", 233 | "`MyString = \"Data Science with Harshit\"`" 234 | ] 235 | }, 236 | { 237 | "cell_type": "code", 238 | "execution_count": 40, 239 | "metadata": {}, 240 | "outputs": [], 241 | "source": [ 242 | "# code and test below...\n", 243 | "\n" 244 | ] 245 | }, 246 | { 247 | "cell_type": "markdown", 248 | "metadata": {}, 249 | "source": [ 250 | "## Q13: Extract the last element of the list without counting.\n", 251 | "\n", 252 | "`MyList = [23, 43, 56, 'tom', 'red', 65, 89, 90, 87]`" 253 | ] 254 | }, 255 | { 256 | "cell_type": "code", 257 | "execution_count": 41, 258 | "metadata": {}, 259 | "outputs": [], 260 | "source": [ 261 | "# code and test below...\n", 262 | "\n" 263 | ] 264 | }, 265 | { 266 | "cell_type": "markdown", 267 | "metadata": {}, 268 | "source": [ 269 | "## Q14: What is the length of the list below?\n", 270 | "\n", 271 | "`MyList = [23, 43, 56, 'tom', 'red', 65, 89, 90, 87]`" 272 | ] 273 | }, 274 | { 275 | "cell_type": "code", 276 | "execution_count": 42, 277 | "metadata": {}, 278 | "outputs": [], 279 | "source": [ 280 | "# code and test below...\n", 281 | "\n" 282 | ] 283 | }, 284 | { 285 | "cell_type": "markdown", 286 | "metadata": {}, 287 | "source": [ 288 | "## Q15: Extract all the elements from 2nd index to 6th index.\n", 289 | "\n", 290 | "`MyList = [23, 43, 56, 'tom', 'red', 65, 89, 90, 87]`" 291 | ] 292 | }, 293 | { 294 | "cell_type": "code", 295 | "execution_count": null, 296 | "metadata": {}, 297 | "outputs": [], 298 | "source": [] 299 | }, 300 | { 301 | "cell_type": "markdown", 302 | "metadata": {}, 303 | "source": [ 304 | "## Q16: Extract all the elements except last 2 using slicing\n", 305 | "\n", 306 | "`MyList = [23, 43, 56, 'tom', 'red', 65, 89, 90, 87]`" 307 | ] 308 | }, 309 | { 310 | "cell_type": "code", 311 | "execution_count": 43, 312 | "metadata": {}, 313 | "outputs": [], 314 | "source": [ 315 | "# code and test below...\n", 316 | "\n" 317 | ] 318 | }, 319 | { 320 | "cell_type": "markdown", 321 | "metadata": {}, 322 | "source": [ 323 | "## Q17: Are lists mutable? (Yes/No)\n", 324 | "\n" 325 | ] 326 | }, 327 | { 328 | "cell_type": "code", 329 | "execution_count": 44, 330 | "metadata": {}, 331 | "outputs": [], 332 | "source": [ 333 | "# code and test below...\n", 334 | "\n" 335 | ] 336 | }, 337 | { 338 | "cell_type": "markdown", 339 | "metadata": {}, 340 | "source": [ 341 | "## Q18: Sort the below list using the in-built list class function:\n", 342 | "\n", 343 | "`MyList = [23, 43, 56, 65, 89, 90, 87]`" 344 | ] 345 | }, 346 | { 347 | "cell_type": "code", 348 | "execution_count": 45, 349 | "metadata": {}, 350 | "outputs": [], 351 | "source": [ 352 | "# code and test below...\n", 353 | "\n" 354 | ] 355 | }, 356 | { 357 | "cell_type": "markdown", 358 | "metadata": {}, 359 | "source": [ 360 | "## Q19: Delete 'tom' and 'red' from the list using remove() function.\n", 361 | "\n", 362 | "`MyList = [23, 43, 56, 'tom', 'red', 65, 89, 90, 87]`" 363 | ] 364 | }, 365 | { 366 | "cell_type": "code", 367 | "execution_count": 46, 368 | "metadata": {}, 369 | "outputs": [], 370 | "source": [ 371 | "# code and test below...\n", 372 | "\n" 373 | ] 374 | }, 375 | { 376 | "cell_type": "markdown", 377 | "metadata": {}, 378 | "source": [ 379 | "## Q20: Tuples are mutable(True/False) \n", 380 | "\n" 381 | ] 382 | }, 383 | { 384 | "cell_type": "code", 385 | "execution_count": 47, 386 | "metadata": {}, 387 | "outputs": [], 388 | "source": [ 389 | "# code and test below...\n", 390 | "\n" 391 | ] 392 | }, 393 | { 394 | "cell_type": "markdown", 395 | "metadata": {}, 396 | "source": [ 397 | "## Q21: From a tuple (23, -1, 34, [1 , 3] , 90), extract 3.\n", 398 | "\n" 399 | ] 400 | }, 401 | { 402 | "cell_type": "code", 403 | "execution_count": 48, 404 | "metadata": {}, 405 | "outputs": [], 406 | "source": [ 407 | "# code and test below...\n", 408 | "\n" 409 | ] 410 | }, 411 | { 412 | "cell_type": "markdown", 413 | "metadata": {}, 414 | "source": [ 415 | "## Q22: What is right method to clone a list? Create a clone the list below. `Imp` (Hint: slicing)\n", 416 | "\n", 417 | "`MyList = [23, 43, 56, 'tom', 'red', 65, 89, 90, 87]`" 418 | ] 419 | }, 420 | { 421 | "cell_type": "code", 422 | "execution_count": 49, 423 | "metadata": {}, 424 | "outputs": [], 425 | "source": [ 426 | "# code and test below...\n", 427 | "\n" 428 | ] 429 | } 430 | ], 431 | "metadata": { 432 | "kernelspec": { 433 | "display_name": "Python 3", 434 | "language": "python", 435 | "name": "python3" 436 | }, 437 | "language_info": { 438 | "codemirror_mode": { 439 | "name": "ipython", 440 | "version": 3 441 | }, 442 | "file_extension": ".py", 443 | "mimetype": "text/x-python", 444 | "name": "python", 445 | "nbconvert_exporter": "python", 446 | "pygments_lexer": "ipython3", 447 | "version": "3.7.4" 448 | } 449 | }, 450 | "nbformat": 4, 451 | "nbformat_minor": 2 452 | } 453 | -------------------------------------------------------------------------------- /Exercises/exercise2_condtionals_loops.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Python fundamentals Exercises (Conditionals, Loops)\n", 8 | "\n", 9 | "The notebook intends to help you practice these concepts. Attempt honestly.\n", 10 | "\n", 11 | "Instructions/Suggestions:\n", 12 | "1. Don't forget to copy the expression from the Question to code cell!\n", 13 | "2. You can use the python documentation anytime you want to learn about a new function or attribute." 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "## Q1: What would be the output of the following code block?\n", 21 | "\n", 22 | "```python\n", 23 | "count = 4\n", 24 | "print(count == 2)\n", 25 | "print(count != 4)\n", 26 | "print(count > 4)\n", 27 | "print(count < 6)\n", 28 | "\n", 29 | "```\n" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": 7, 35 | "metadata": {}, 36 | "outputs": [], 37 | "source": [ 38 | "# code and test below\n", 39 | "\n" 40 | ] 41 | }, 42 | { 43 | "cell_type": "markdown", 44 | "metadata": {}, 45 | "source": [ 46 | "## Q2: What would be the output of the following code block?\n", 47 | "\n", 48 | "```python\n", 49 | "color = \"red\"\n", 50 | "category = \"fruit\"\n", 51 | "\n", 52 | "if color == \"red\" and category == \"fruit\":\n", 53 | " print(\"We have an Apple!)\n", 54 | "\n", 55 | "if color == \"red\" and category == \"vegetable\":\n", 56 | " print(\"We have tomatoes\")\n", 57 | "\n", 58 | "```\n" 59 | ] 60 | }, 61 | { 62 | "cell_type": "code", 63 | "execution_count": null, 64 | "metadata": {}, 65 | "outputs": [], 66 | "source": [ 67 | "# code and test below\n", 68 | "\n" 69 | ] 70 | }, 71 | { 72 | "cell_type": "markdown", 73 | "metadata": {}, 74 | "source": [ 75 | "## Q3: What would be the output of the following code block?\n", 76 | "\n", 77 | "```python\n", 78 | "requested = ['blueberry', 'banana']\n", 79 | "fruits = ['apple', 'banana', 'watermelon', 'kiwi', 'rasberry']\n", 80 | "\n", 81 | "if requested not in fruits:\n", 82 | " print(\"Sorry, We don't have bananas in stock. Please review your order!\")\n", 83 | "\n", 84 | "else:\n", 85 | " print(\"Order is placed!\")\n", 86 | "\n", 87 | "```" 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "execution_count": 14, 93 | "metadata": {}, 94 | "outputs": [], 95 | "source": [ 96 | "# code and test below\n", 97 | "\n", 98 | " \n" 99 | ] 100 | }, 101 | { 102 | "cell_type": "markdown", 103 | "metadata": {}, 104 | "source": [ 105 | "## Q4: What would be the output of the following code block?\n", 106 | "\n", 107 | "```python\n", 108 | "scores1 = [1,2,3]\n", 109 | "scores2 = [1,2,3]\n", 110 | "\n", 111 | "print(score1 == score2)\n", 112 | "\n", 113 | "```" 114 | ] 115 | }, 116 | { 117 | "cell_type": "code", 118 | "execution_count": null, 119 | "metadata": {}, 120 | "outputs": [], 121 | "source": [ 122 | "# code and test below\n", 123 | "\n" 124 | ] 125 | }, 126 | { 127 | "cell_type": "markdown", 128 | "metadata": {}, 129 | "source": [ 130 | "## Q5: What would be the output of the following code block? Learn about 'is' operator.\n", 131 | "\n", 132 | "```python\n", 133 | "scores1 = [1,2,3]\n", 134 | "scores2 = [1,2,3]\n", 135 | "\n", 136 | "print(score1 == score2)\n", 137 | "print(score1 is score2)\n", 138 | "\n", 139 | "```" 140 | ] 141 | }, 142 | { 143 | "cell_type": "code", 144 | "execution_count": null, 145 | "metadata": {}, 146 | "outputs": [], 147 | "source": [ 148 | "# code and test below\n", 149 | "\n" 150 | ] 151 | }, 152 | { 153 | "cell_type": "markdown", 154 | "metadata": {}, 155 | "source": [ 156 | "## Q6: Print the following pattern using for loops:\n", 157 | "\n", 158 | "*\n", 159 | "**\n", 160 | "***\n", 161 | "****\n", 162 | ".\n", 163 | ".\n", 164 | ".\n", 165 | "*****....*(n times)\n", 166 | "\n" 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": null, 172 | "metadata": {}, 173 | "outputs": [], 174 | "source": [ 175 | "# code and test below\n", 176 | "\n" 177 | ] 178 | }, 179 | { 180 | "cell_type": "code", 181 | "execution_count": null, 182 | "metadata": {}, 183 | "outputs": [], 184 | "source": [ 185 | "## Q3: What would be the output of the following code block?\n", 186 | "\n", 187 | "```python\n", 188 | "scores = [67, 90, 89, 78, 99, 100]\n", 189 | "for score in \n", 190 | "\n", 191 | "```" 192 | ] 193 | }, 194 | { 195 | "cell_type": "code", 196 | "execution_count": null, 197 | "metadata": {}, 198 | "outputs": [], 199 | "source": [ 200 | "# code and test below\n", 201 | "\n" 202 | ] 203 | }, 204 | { 205 | "cell_type": "code", 206 | "execution_count": null, 207 | "metadata": {}, 208 | "outputs": [], 209 | "source": [] 210 | }, 211 | { 212 | "cell_type": "code", 213 | "execution_count": null, 214 | "metadata": {}, 215 | "outputs": [], 216 | "source": [] 217 | }, 218 | { 219 | "cell_type": "code", 220 | "execution_count": null, 221 | "metadata": {}, 222 | "outputs": [], 223 | "source": [] 224 | }, 225 | { 226 | "cell_type": "code", 227 | "execution_count": null, 228 | "metadata": {}, 229 | "outputs": [], 230 | "source": [] 231 | } 232 | ], 233 | "metadata": { 234 | "kernelspec": { 235 | "display_name": "Python 3", 236 | "language": "python", 237 | "name": "python3" 238 | }, 239 | "language_info": { 240 | "codemirror_mode": { 241 | "name": "ipython", 242 | "version": 3 243 | }, 244 | "file_extension": ".py", 245 | "mimetype": "text/x-python", 246 | "name": "python", 247 | "nbconvert_exporter": "python", 248 | "pygments_lexer": "ipython3", 249 | "version": "3.7.4" 250 | } 251 | }, 252 | "nbformat": 4, 253 | "nbformat_minor": 2 254 | } 255 | -------------------------------------------------------------------------------- /Exercises/exercise3_dictionaries_functions.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Python fundamentals Exercises (Dictionaries, Functions)\n", 8 | "\n", 9 | "The notebook intends to help you practice these concepts. Attempt honestly.\n", 10 | "\n", 11 | "Instructions/Suggestions:\n", 12 | "1. Don't forget to copy the expression from the Question to code cell!\n", 13 | "2. You can use the python documentation anytime you want to learn about a new function or attribute." 14 | ] 15 | }, 16 | { 17 | "cell_type": "markdown", 18 | "metadata": {}, 19 | "source": [ 20 | "## Q1: What are the keys in the following dictionary?\n", 21 | "\n", 22 | "`MyDict = {\"Color\": \"red\", \"name\": \"apple\", \"type\": \"fruit\"}`\n", 23 | "\n", 24 | "### Type your answers below:" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": {}, 30 | "source": [ 31 | "## Q2: Extract all the keys of the dictionary below.\n", 32 | "\n", 33 | "`MyDict = {\"Color\": \"red\", \"name\": \"apple\", \"type\": \"fruit\"}`\n" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": 2, 39 | "metadata": {}, 40 | "outputs": [], 41 | "source": [ 42 | "# code and test below...\n", 43 | "\n" 44 | ] 45 | }, 46 | { 47 | "cell_type": "markdown", 48 | "metadata": {}, 49 | "source": [ 50 | "## Q2: Iterate over the dictionary to print the corresponding key and value.\n", 51 | "\n", 52 | "`MyDict = {\"Color\": \"red\", \"name\": \"apple\", \"type\": \"fruit\"}`\n", 53 | "\n" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": null, 59 | "metadata": {}, 60 | "outputs": [], 61 | "source": [] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": null, 66 | "metadata": {}, 67 | "outputs": [], 68 | "source": [] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": null, 73 | "metadata": {}, 74 | "outputs": [], 75 | "source": [] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": null, 80 | "metadata": {}, 81 | "outputs": [], 82 | "source": [] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": null, 87 | "metadata": {}, 88 | "outputs": [], 89 | "source": [] 90 | }, 91 | { 92 | "cell_type": "code", 93 | "execution_count": null, 94 | "metadata": {}, 95 | "outputs": [], 96 | "source": [] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": null, 101 | "metadata": {}, 102 | "outputs": [], 103 | "source": [] 104 | }, 105 | { 106 | "cell_type": "code", 107 | "execution_count": null, 108 | "metadata": {}, 109 | "outputs": [], 110 | "source": [] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": null, 115 | "metadata": {}, 116 | "outputs": [], 117 | "source": [] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": null, 122 | "metadata": {}, 123 | "outputs": [], 124 | "source": [] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": null, 129 | "metadata": {}, 130 | "outputs": [], 131 | "source": [] 132 | }, 133 | { 134 | "cell_type": "code", 135 | "execution_count": null, 136 | "metadata": {}, 137 | "outputs": [], 138 | "source": [] 139 | }, 140 | { 141 | "cell_type": "code", 142 | "execution_count": null, 143 | "metadata": {}, 144 | "outputs": [], 145 | "source": [] 146 | }, 147 | { 148 | "cell_type": "code", 149 | "execution_count": null, 150 | "metadata": {}, 151 | "outputs": [], 152 | "source": [] 153 | }, 154 | { 155 | "cell_type": "code", 156 | "execution_count": null, 157 | "metadata": {}, 158 | "outputs": [], 159 | "source": [] 160 | }, 161 | { 162 | "cell_type": "code", 163 | "execution_count": null, 164 | "metadata": {}, 165 | "outputs": [], 166 | "source": [] 167 | }, 168 | { 169 | "cell_type": "code", 170 | "execution_count": null, 171 | "metadata": {}, 172 | "outputs": [], 173 | "source": [] 174 | }, 175 | { 176 | "cell_type": "code", 177 | "execution_count": null, 178 | "metadata": {}, 179 | "outputs": [], 180 | "source": [] 181 | }, 182 | { 183 | "cell_type": "code", 184 | "execution_count": null, 185 | "metadata": {}, 186 | "outputs": [], 187 | "source": [] 188 | }, 189 | { 190 | "cell_type": "code", 191 | "execution_count": null, 192 | "metadata": {}, 193 | "outputs": [], 194 | "source": [] 195 | }, 196 | { 197 | "cell_type": "code", 198 | "execution_count": null, 199 | "metadata": {}, 200 | "outputs": [], 201 | "source": [] 202 | }, 203 | { 204 | "cell_type": "code", 205 | "execution_count": null, 206 | "metadata": {}, 207 | "outputs": [], 208 | "source": [] 209 | }, 210 | { 211 | "cell_type": "code", 212 | "execution_count": null, 213 | "metadata": {}, 214 | "outputs": [], 215 | "source": [] 216 | }, 217 | { 218 | "cell_type": "code", 219 | "execution_count": null, 220 | "metadata": {}, 221 | "outputs": [], 222 | "source": [] 223 | }, 224 | { 225 | "cell_type": "code", 226 | "execution_count": null, 227 | "metadata": {}, 228 | "outputs": [], 229 | "source": [] 230 | }, 231 | { 232 | "cell_type": "code", 233 | "execution_count": null, 234 | "metadata": {}, 235 | "outputs": [], 236 | "source": [] 237 | }, 238 | { 239 | "cell_type": "code", 240 | "execution_count": null, 241 | "metadata": {}, 242 | "outputs": [], 243 | "source": [] 244 | }, 245 | { 246 | "cell_type": "code", 247 | "execution_count": null, 248 | "metadata": {}, 249 | "outputs": [], 250 | "source": [] 251 | }, 252 | { 253 | "cell_type": "code", 254 | "execution_count": null, 255 | "metadata": {}, 256 | "outputs": [], 257 | "source": [] 258 | }, 259 | { 260 | "cell_type": "code", 261 | "execution_count": null, 262 | "metadata": {}, 263 | "outputs": [], 264 | "source": [] 265 | }, 266 | { 267 | "cell_type": "code", 268 | "execution_count": null, 269 | "metadata": {}, 270 | "outputs": [], 271 | "source": [] 272 | }, 273 | { 274 | "cell_type": "code", 275 | "execution_count": null, 276 | "metadata": {}, 277 | "outputs": [], 278 | "source": [] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "execution_count": null, 283 | "metadata": {}, 284 | "outputs": [], 285 | "source": [] 286 | } 287 | ], 288 | "metadata": { 289 | "kernelspec": { 290 | "display_name": "Python 3", 291 | "language": "python", 292 | "name": "python3" 293 | }, 294 | "language_info": { 295 | "codemirror_mode": { 296 | "name": "ipython", 297 | "version": 3 298 | }, 299 | "file_extension": ".py", 300 | "mimetype": "text/x-python", 301 | "name": "python", 302 | "nbconvert_exporter": "python", 303 | "pygments_lexer": "ipython3", 304 | "version": "3.7.4" 305 | } 306 | }, 307 | "nbformat": 4, 308 | "nbformat_minor": 2 309 | } 310 | -------------------------------------------------------------------------------- /Notebooks/Numpy_fundamentals.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "alist = [1,5,6,7,'harshit']" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 2, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import numpy as np\n", 19 | "\n", 20 | "np_arr = np.array(alist)" 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": 3, 26 | "metadata": {}, 27 | "outputs": [ 28 | { 29 | "data": { 30 | "text/plain": [ 31 | "array(['1', '5', '6', '7', 'harshit'], dtype=']" 522 | ] 523 | }, 524 | "execution_count": 47, 525 | "metadata": {}, 526 | "output_type": "execute_result" 527 | }, 528 | { 529 | "data": { 530 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZ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RyL13iJuy/sNfc8qj+rEQupqMYAAAI3SURBVBnoBLcGe9Rx99f44KJlvdeSfwj48yEtKoTcvdLdNwSeN9MTBrnE1jW6u7cEDpMCDwcupWcvAIjyawQws0nAR4GfBY6NGLvGE4jqz2qkBnowa7DHignuXgk9gQiMD3M9IRHYhnARsI4Yu8bAUMQmoAZYDbwHNAT2AoDY+Lz+B/B3QHfgeByxd40OvGBm681seeC1qP6sRuom0UGtry6RycxSgKeAv3H3pljbvMrdu4CFZpYB/AaY3V+zoa0qdMzsaqDG3deb2cXvv9xP06i9xoCl7n7QzMYDq82sNNwFna5I7aEHswZ7rKg2sxyAwL81Ya7ntJhZEj1h/nN3/3Xg5Zi6xve5ewPwCj3fF2QE9gKA6P+8LgWuMbO99Ax3XkpPjz2WrhF3Pxj4t4aeP8yLifLPaqQGejBrsMeK3mvJ3wSsDGMtpyUwznofUOLuP+x1KpauMSvQM8fMRgKX0/Ndwcv07AUAUX6N7n6nu09y9wJ6fvfWuPtniKFrNLPRZpb6/nPgI8BWovyzGrF3iprZVfT0Ct5fg/27YS7ptJnZL4GL6Vmisxq4C3gaeBzIB/YD17t7VO72ZGbnA68D7/LHsddv0zOOHivXOJ+eL8sS6ekQPe7ud5vZVHp6s2OBjcBn3b0tfJWGRmDI5Q53vzqWrjFwLb8JHA4DfuHu3zWzcUTxZzViA11ERE5OpA65iIjISVKgi4jECAW6iEiMUKCLiMQIBbqISIxQoIuIxAgFuohIjPj/wTbG15T3cJgAAAAASUVORK5CYII=\n", 531 | "text/plain": [ 532 | "
" 533 | ] 534 | }, 535 | "metadata": { 536 | "needs_background": "light" 537 | }, 538 | "output_type": "display_data" 539 | } 540 | ], 541 | "source": [ 542 | "import matplotlib.pyplot as plt\n", 543 | "%matplotlib inline\n", 544 | "\n", 545 | "plt.plot(x,y)\n", 546 | "\n" 547 | ] 548 | }, 549 | { 550 | "cell_type": "code", 551 | "execution_count": 48, 552 | "metadata": {}, 553 | "outputs": [], 554 | "source": [ 555 | "md_arr = np.array([[1,2,3],[4,5,6]])" 556 | ] 557 | }, 558 | { 559 | "cell_type": "code", 560 | "execution_count": 49, 561 | "metadata": {}, 562 | "outputs": [ 563 | { 564 | "data": { 565 | "text/plain": [ 566 | "array([[1, 2, 3],\n", 567 | " [4, 5, 6]])" 568 | ] 569 | }, 570 | "execution_count": 49, 571 | "metadata": {}, 572 | "output_type": "execute_result" 573 | } 574 | ], 575 | "source": [ 576 | "md_arr" 577 | ] 578 | }, 579 | { 580 | "cell_type": "code", 581 | "execution_count": 50, 582 | "metadata": {}, 583 | "outputs": [], 584 | "source": [ 585 | "md_arr = np.array([[2*i +j for j in range(4)] for i in range(3)])" 586 | ] 587 | }, 588 | { 589 | "cell_type": "code", 590 | "execution_count": 51, 591 | "metadata": {}, 592 | "outputs": [ 593 | { 594 | "data": { 595 | "text/plain": [ 596 | "array([[0, 1, 2, 3],\n", 597 | " [2, 3, 4, 5],\n", 598 | " [4, 5, 6, 7]])" 599 | ] 600 | }, 601 | "execution_count": 51, 602 | "metadata": {}, 603 | "output_type": "execute_result" 604 | } 605 | ], 606 | "source": [ 607 | "md_arr" 608 | ] 609 | }, 610 | { 611 | "cell_type": "code", 612 | "execution_count": 53, 613 | "metadata": {}, 614 | "outputs": [ 615 | { 616 | "data": { 617 | "text/plain": [ 618 | "array([ 0, 5, 10, 15, 20, 25])" 619 | ] 620 | }, 621 | "execution_count": 53, 622 | "metadata": {}, 623 | "output_type": "execute_result" 624 | } 625 | ], 626 | "source": [ 627 | "np.arange(0,26,5)" 628 | ] 629 | }, 630 | { 631 | "cell_type": "code", 632 | "execution_count": 54, 633 | "metadata": {}, 634 | "outputs": [ 635 | { 636 | "data": { 637 | "text/plain": [ 638 | "array([[0., 0., 0., 0.],\n", 639 | " [0., 0., 0., 0.],\n", 640 | " [0., 0., 0., 0.]])" 641 | ] 642 | }, 643 | "execution_count": 54, 644 | "metadata": {}, 645 | "output_type": "execute_result" 646 | } 647 | ], 648 | "source": [ 649 | "np.zeros((3,4))" 650 | ] 651 | }, 652 | { 653 | "cell_type": "code", 654 | "execution_count": 56, 655 | "metadata": {}, 656 | "outputs": [ 657 | { 658 | "data": { 659 | "text/plain": [ 660 | "1" 661 | ] 662 | }, 663 | "execution_count": 56, 664 | "metadata": {}, 665 | "output_type": "execute_result" 666 | } 667 | ], 668 | "source": [ 669 | "md_arr[0][1]" 670 | ] 671 | }, 672 | { 673 | "cell_type": "code", 674 | "execution_count": 59, 675 | "metadata": {}, 676 | "outputs": [ 677 | { 678 | "data": { 679 | "text/plain": [ 680 | "array([[0, 1, 2, 3],\n", 681 | " [2, 3, 4, 5],\n", 682 | " [4, 5, 6, 7]])" 683 | ] 684 | }, 685 | "execution_count": 59, 686 | "metadata": {}, 687 | "output_type": "execute_result" 688 | } 689 | ], 690 | "source": [ 691 | "md_arr[0,1]\n", 692 | "md_arr" 693 | ] 694 | }, 695 | { 696 | "cell_type": "code", 697 | "execution_count": 58, 698 | "metadata": {}, 699 | "outputs": [ 700 | { 701 | "data": { 702 | "text/plain": [ 703 | "array([1, 2])" 704 | ] 705 | }, 706 | "execution_count": 58, 707 | "metadata": {}, 708 | "output_type": "execute_result" 709 | } 710 | ], 711 | "source": [ 712 | "md_arr[0][1:3]" 713 | ] 714 | }, 715 | { 716 | "cell_type": "code", 717 | "execution_count": 63, 718 | "metadata": {}, 719 | "outputs": [ 720 | { 721 | "data": { 722 | "text/plain": [ 723 | "array([[[1],\n", 724 | " [2],\n", 725 | " [3]],\n", 726 | "\n", 727 | " [[4],\n", 728 | " [5],\n", 729 | " [6]]])" 730 | ] 731 | }, 732 | "execution_count": 63, 733 | "metadata": {}, 734 | "output_type": "execute_result" 735 | } 736 | ], 737 | "source": [ 738 | "arr3 = np.array([[[1],[2],[3]], [[4],[5],[6]]])\n", 739 | "arr3" 740 | ] 741 | }, 742 | { 743 | "cell_type": "code", 744 | "execution_count": 64, 745 | "metadata": {}, 746 | "outputs": [ 747 | { 748 | "data": { 749 | "text/plain": [ 750 | "3" 751 | ] 752 | }, 753 | "execution_count": 64, 754 | "metadata": {}, 755 | "output_type": "execute_result" 756 | } 757 | ], 758 | "source": [ 759 | "arr3.ndim" 760 | ] 761 | }, 762 | { 763 | "cell_type": "code", 764 | "execution_count": 65, 765 | "metadata": {}, 766 | "outputs": [ 767 | { 768 | "data": { 769 | "text/plain": [ 770 | "12" 771 | ] 772 | }, 773 | "execution_count": 65, 774 | "metadata": {}, 775 | "output_type": "execute_result" 776 | } 777 | ], 778 | "source": [ 779 | "md_arr.size" 780 | ] 781 | }, 782 | { 783 | "cell_type": "code", 784 | "execution_count": 66, 785 | "metadata": {}, 786 | "outputs": [ 787 | { 788 | "data": { 789 | "text/plain": [ 790 | "(3, 4)" 791 | ] 792 | }, 793 | "execution_count": 66, 794 | "metadata": {}, 795 | "output_type": "execute_result" 796 | } 797 | ], 798 | "source": [ 799 | "md_arr.shape" 800 | ] 801 | }, 802 | { 803 | "cell_type": "code", 804 | "execution_count": 67, 805 | "metadata": {}, 806 | "outputs": [ 807 | { 808 | "data": { 809 | "text/plain": [ 810 | "array([[3, 1],\n", 811 | " [3, 2]])" 812 | ] 813 | }, 814 | "execution_count": 67, 815 | "metadata": {}, 816 | "output_type": "execute_result" 817 | } 818 | ], 819 | "source": [ 820 | "a1 = np.array([[1,0], [2,1]])\n", 821 | "a2 = np.array([[2,1], [1,1]])\n", 822 | "\n", 823 | "a1 + a2" 824 | ] 825 | }, 826 | { 827 | "cell_type": "code", 828 | "execution_count": 69, 829 | "metadata": {}, 830 | "outputs": [ 831 | { 832 | "data": { 833 | "text/plain": [ 834 | "array([[1, 0],\n", 835 | " [2, 1]])" 836 | ] 837 | }, 838 | "execution_count": 69, 839 | "metadata": {}, 840 | "output_type": "execute_result" 841 | } 842 | ], 843 | "source": [ 844 | "a1" 845 | ] 846 | }, 847 | { 848 | "cell_type": "code", 849 | "execution_count": 70, 850 | "metadata": {}, 851 | "outputs": [ 852 | { 853 | "data": { 854 | "text/plain": [ 855 | "array([[2, 0],\n", 856 | " [4, 2]])" 857 | ] 858 | }, 859 | "execution_count": 70, 860 | "metadata": {}, 861 | "output_type": "execute_result" 862 | } 863 | ], 864 | "source": [ 865 | "2*a1" 866 | ] 867 | }, 868 | { 869 | "cell_type": "code", 870 | "execution_count": 71, 871 | "metadata": {}, 872 | "outputs": [ 873 | { 874 | "data": { 875 | "text/plain": [ 876 | "array([[2, 1],\n", 877 | " [5, 3]])" 878 | ] 879 | }, 880 | "execution_count": 71, 881 | "metadata": {}, 882 | "output_type": "execute_result" 883 | } 884 | ], 885 | "source": [ 886 | "# dot product\n", 887 | "\n", 888 | "np.dot(a1,a2)" 889 | ] 890 | }, 891 | { 892 | "cell_type": "code", 893 | "execution_count": 75, 894 | "metadata": {}, 895 | "outputs": [ 896 | { 897 | "data": { 898 | "text/plain": [ 899 | "array([[1, 0],\n", 900 | " [2, 1]])" 901 | ] 902 | }, 903 | "execution_count": 75, 904 | "metadata": {}, 905 | "output_type": "execute_result" 906 | } 907 | ], 908 | "source": [ 909 | "# array manipulation\n", 910 | "a1" 911 | ] 912 | }, 913 | { 914 | "cell_type": "code", 915 | "execution_count": 73, 916 | "metadata": {}, 917 | "outputs": [], 918 | "source": [ 919 | "arr_t = np.transpose(a1)" 920 | ] 921 | }, 922 | { 923 | "cell_type": "code", 924 | "execution_count": 74, 925 | "metadata": {}, 926 | "outputs": [ 927 | { 928 | "data": { 929 | "text/plain": [ 930 | "array([[1, 2],\n", 931 | " [0, 1]])" 932 | ] 933 | }, 934 | "execution_count": 74, 935 | "metadata": {}, 936 | "output_type": "execute_result" 937 | } 938 | ], 939 | "source": [ 940 | "arr_t" 941 | ] 942 | }, 943 | { 944 | "cell_type": "code", 945 | "execution_count": 76, 946 | "metadata": {}, 947 | "outputs": [ 948 | { 949 | "data": { 950 | "text/plain": [ 951 | "array([[1, 2],\n", 952 | " [0, 1]])" 953 | ] 954 | }, 955 | "execution_count": 76, 956 | "metadata": {}, 957 | "output_type": "execute_result" 958 | } 959 | ], 960 | "source": [ 961 | "a1.T" 962 | ] 963 | }, 964 | { 965 | "cell_type": "code", 966 | "execution_count": 77, 967 | "metadata": {}, 968 | "outputs": [ 969 | { 970 | "data": { 971 | "text/plain": [ 972 | "(2, 2)" 973 | ] 974 | }, 975 | "execution_count": 77, 976 | "metadata": {}, 977 | "output_type": "execute_result" 978 | } 979 | ], 980 | "source": [ 981 | "a1.shape" 982 | ] 983 | }, 984 | { 985 | "cell_type": "code", 986 | "execution_count": 81, 987 | "metadata": {}, 988 | "outputs": [], 989 | "source": [ 990 | "n = a1.reshape(4,1)" 991 | ] 992 | }, 993 | { 994 | "cell_type": "code", 995 | "execution_count": 80, 996 | "metadata": {}, 997 | "outputs": [ 998 | { 999 | "data": { 1000 | "text/plain": [ 1001 | "2" 1002 | ] 1003 | }, 1004 | "execution_count": 80, 1005 | "metadata": {}, 1006 | "output_type": "execute_result" 1007 | } 1008 | ], 1009 | "source": [ 1010 | "n.ndim" 1011 | ] 1012 | }, 1013 | { 1014 | "cell_type": "code", 1015 | "execution_count": 82, 1016 | "metadata": {}, 1017 | "outputs": [ 1018 | { 1019 | "data": { 1020 | "text/plain": [ 1021 | "array([[1],\n", 1022 | " [0],\n", 1023 | " [2],\n", 1024 | " [1]])" 1025 | ] 1026 | }, 1027 | "execution_count": 82, 1028 | "metadata": {}, 1029 | "output_type": "execute_result" 1030 | } 1031 | ], 1032 | "source": [ 1033 | "n" 1034 | ] 1035 | }, 1036 | { 1037 | "cell_type": "code", 1038 | "execution_count": 91, 1039 | "metadata": {}, 1040 | "outputs": [ 1041 | { 1042 | "data": { 1043 | "text/plain": [ 1044 | "array([[1, 0],\n", 1045 | " [2, 1],\n", 1046 | " [2, 1],\n", 1047 | " [1, 1]])" 1048 | ] 1049 | }, 1050 | "execution_count": 91, 1051 | "metadata": {}, 1052 | "output_type": "execute_result" 1053 | } 1054 | ], 1055 | "source": [ 1056 | "np.concatenate((a1,a2))" 1057 | ] 1058 | }, 1059 | { 1060 | "cell_type": "code", 1061 | "execution_count": 92, 1062 | "metadata": {}, 1063 | "outputs": [ 1064 | { 1065 | "data": { 1066 | "text/plain": [ 1067 | "array([[1, 0],\n", 1068 | " [2, 1],\n", 1069 | " [2, 1],\n", 1070 | " [1, 1]])" 1071 | ] 1072 | }, 1073 | "execution_count": 92, 1074 | "metadata": {}, 1075 | "output_type": "execute_result" 1076 | } 1077 | ], 1078 | "source": [ 1079 | "np.vstack((a1,a2))" 1080 | ] 1081 | }, 1082 | { 1083 | "cell_type": "code", 1084 | "execution_count": 93, 1085 | "metadata": {}, 1086 | "outputs": [ 1087 | { 1088 | "data": { 1089 | "text/plain": [ 1090 | "array([[1, 0, 2, 1],\n", 1091 | " [2, 1, 1, 1]])" 1092 | ] 1093 | }, 1094 | "execution_count": 93, 1095 | "metadata": {}, 1096 | "output_type": "execute_result" 1097 | } 1098 | ], 1099 | "source": [ 1100 | "np.hstack((a1,a2))" 1101 | ] 1102 | }, 1103 | { 1104 | "cell_type": "code", 1105 | "execution_count": null, 1106 | "metadata": {}, 1107 | "outputs": [], 1108 | "source": [] 1109 | } 1110 | ], 1111 | "metadata": { 1112 | "kernelspec": { 1113 | "display_name": "Python 3", 1114 | "language": "python", 1115 | "name": "python3" 1116 | }, 1117 | "language_info": { 1118 | "codemirror_mode": { 1119 | "name": "ipython", 1120 | "version": 3 1121 | }, 1122 | "file_extension": ".py", 1123 | "mimetype": "text/x-python", 1124 | "name": "python", 1125 | "nbconvert_exporter": "python", 1126 | "pygments_lexer": "ipython3", 1127 | "version": "3.7.4" 1128 | } 1129 | }, 1130 | "nbformat": 4, 1131 | "nbformat_minor": 2 1132 | } 1133 | -------------------------------------------------------------------------------- /Notebooks/python_fundamentals_part-1.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Python Fundamentals - part I\n", 8 | "\n", 9 | "The notebook intends to cover the following topics:\n", 10 | "1. I/O functions\n", 11 | "2. Data types / Variables\n", 12 | "3. String operations and formatting\n", 13 | "4. Arithmetic operations\n", 14 | "5. Introduction to lists" 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": 1, 20 | "metadata": {}, 21 | "outputs": [ 22 | { 23 | "name": "stdout", 24 | "output_type": "stream", 25 | "text": [ 26 | "Hello World!\n" 27 | ] 28 | } 29 | ], 30 | "source": [ 31 | "print(\"Hello World!\")" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": 2, 37 | "metadata": {}, 38 | "outputs": [ 39 | { 40 | "name": "stdout", 41 | "output_type": "stream", 42 | "text": [ 43 | "data science\n" 44 | ] 45 | }, 46 | { 47 | "data": { 48 | "text/plain": [ 49 | "'data science'" 50 | ] 51 | }, 52 | "execution_count": 2, 53 | "metadata": {}, 54 | "output_type": "execute_result" 55 | } 56 | ], 57 | "source": [ 58 | "input()" 59 | ] 60 | }, 61 | { 62 | "cell_type": "code", 63 | "execution_count": 3, 64 | "metadata": {}, 65 | "outputs": [ 66 | { 67 | "name": "stdout", 68 | "output_type": "stream", 69 | "text": [ 70 | "a equals 5\n" 71 | ] 72 | } 73 | ], 74 | "source": [ 75 | "a = 5\n", 76 | "if a == 5:\n", 77 | " # 4 indented spaces to this block of code\n", 78 | " print(\"a equals 5\")" 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": 4, 84 | "metadata": {}, 85 | "outputs": [ 86 | { 87 | "name": "stdout", 88 | "output_type": "stream", 89 | "text": [ 90 | "\n" 91 | ] 92 | } 93 | ], 94 | "source": [ 95 | "myString = 'hello world'\n", 96 | "print(type(myString))" 97 | ] 98 | }, 99 | { 100 | "cell_type": "code", 101 | "execution_count": 5, 102 | "metadata": {}, 103 | "outputs": [ 104 | { 105 | "name": "stdout", 106 | "output_type": "stream", 107 | "text": [ 108 | "\n" 109 | ] 110 | } 111 | ], 112 | "source": [ 113 | "n = 10\n", 114 | "print(type(n))" 115 | ] 116 | }, 117 | { 118 | "cell_type": "code", 119 | "execution_count": 7, 120 | "metadata": {}, 121 | "outputs": [ 122 | { 123 | "name": "stdout", 124 | "output_type": "stream", 125 | "text": [ 126 | "\n" 127 | ] 128 | } 129 | ], 130 | "source": [ 131 | "n_float = 7.5\n", 132 | "print(type(n_float))" 133 | ] 134 | }, 135 | { 136 | "cell_type": "code", 137 | "execution_count": 11, 138 | "metadata": {}, 139 | "outputs": [ 140 | { 141 | "ename": "SyntaxError", 142 | "evalue": "invalid syntax (, line 1)", 143 | "output_type": "error", 144 | "traceback": [ 145 | "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m single_string = 'It's a single quote string'\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" 146 | ] 147 | } 148 | ], 149 | "source": [ 150 | "single_string = 'Its a single quote string'\n", 151 | "print(single_string)" 152 | ] 153 | }, 154 | { 155 | "cell_type": "code", 156 | "execution_count": 13, 157 | "metadata": {}, 158 | "outputs": [ 159 | { 160 | "name": "stdout", 161 | "output_type": "stream", 162 | "text": [ 163 | "It's a double quote string\n" 164 | ] 165 | } 166 | ], 167 | "source": [ 168 | "double_string = \"It's a double quote string\"\n", 169 | "print(double_string)" 170 | ] 171 | }, 172 | { 173 | "cell_type": "code", 174 | "execution_count": 14, 175 | "metadata": {}, 176 | "outputs": [ 177 | { 178 | "name": "stdout", 179 | "output_type": "stream", 180 | "text": [ 181 | "12.5\n" 182 | ] 183 | } 184 | ], 185 | "source": [ 186 | "n1 = 5\n", 187 | "n2 = 7.5\n", 188 | "print(n1+n2)" 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": 18, 194 | "metadata": {}, 195 | "outputs": [ 196 | { 197 | "ename": "TypeError", 198 | "evalue": "can only concatenate str (not \"int\") to str", 199 | "output_type": "error", 200 | "traceback": [ 201 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 202 | "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", 203 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mnstr1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"abc\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnstr1\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mn1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 204 | "\u001b[0;31mTypeError\u001b[0m: can only concatenate str (not \"int\") to str" 205 | ] 206 | } 207 | ], 208 | "source": [ 209 | "nstr1 = \"abc\"\n", 210 | "print(nstr1 + n1)" 211 | ] 212 | }, 213 | { 214 | "cell_type": "code", 215 | "execution_count": 19, 216 | "metadata": {}, 217 | "outputs": [ 218 | { 219 | "name": "stdout", 220 | "output_type": "stream", 221 | "text": [ 222 | "abcdef\n" 223 | ] 224 | } 225 | ], 226 | "source": [ 227 | "nstr2 = \"def\"\n", 228 | "print(nstr1 + nstr2)" 229 | ] 230 | }, 231 | { 232 | "cell_type": "code", 233 | "execution_count": 23, 234 | "metadata": {}, 235 | "outputs": [], 236 | "source": [ 237 | "n1, n2 = 10, 11" 238 | ] 239 | }, 240 | { 241 | "cell_type": "code", 242 | "execution_count": 24, 243 | "metadata": {}, 244 | "outputs": [ 245 | { 246 | "data": { 247 | "text/plain": [ 248 | "10" 249 | ] 250 | }, 251 | "execution_count": 24, 252 | "metadata": {}, 253 | "output_type": "execute_result" 254 | } 255 | ], 256 | "source": [ 257 | "n1" 258 | ] 259 | }, 260 | { 261 | "cell_type": "code", 262 | "execution_count": 25, 263 | "metadata": {}, 264 | "outputs": [ 265 | { 266 | "data": { 267 | "text/plain": [ 268 | "11" 269 | ] 270 | }, 271 | "execution_count": 25, 272 | "metadata": {}, 273 | "output_type": "execute_result" 274 | } 275 | ], 276 | "source": [ 277 | "n2" 278 | ] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "execution_count": 27, 283 | "metadata": {}, 284 | "outputs": [ 285 | { 286 | "name": "stdout", 287 | "output_type": "stream", 288 | "text": [ 289 | "13.0\n" 290 | ] 291 | } 292 | ], 293 | "source": [ 294 | "result = 3 + 4.0 / 2 * 5 # DMAS\n", 295 | "print(result)" 296 | ] 297 | }, 298 | { 299 | "cell_type": "code", 300 | "execution_count": 28, 301 | "metadata": {}, 302 | "outputs": [ 303 | { 304 | "name": "stdout", 305 | "output_type": "stream", 306 | "text": [ 307 | "7\n" 308 | ] 309 | } 310 | ], 311 | "source": [ 312 | "# module operator %\n", 313 | "remainder = 17%10\n", 314 | "print(remainder)" 315 | ] 316 | }, 317 | { 318 | "cell_type": "code", 319 | "execution_count": 29, 320 | "metadata": {}, 321 | "outputs": [ 322 | { 323 | "name": "stdout", 324 | "output_type": "stream", 325 | "text": [ 326 | "625\n" 327 | ] 328 | } 329 | ], 330 | "source": [ 331 | "# x ^ n\n", 332 | "x = 5\n", 333 | "n = 4\n", 334 | "print(x ** n)" 335 | ] 336 | }, 337 | { 338 | "cell_type": "code", 339 | "execution_count": 31, 340 | "metadata": {}, 341 | "outputs": [], 342 | "source": [ 343 | "nstr = \"abc\"\n", 344 | "ans = nstr * 10" 345 | ] 346 | }, 347 | { 348 | "cell_type": "code", 349 | "execution_count": 32, 350 | "metadata": {}, 351 | "outputs": [ 352 | { 353 | "name": "stdout", 354 | "output_type": "stream", 355 | "text": [ 356 | "30\n" 357 | ] 358 | } 359 | ], 360 | "source": [ 361 | "print(len(ans))" 362 | ] 363 | }, 364 | { 365 | "cell_type": "code", 366 | "execution_count": 39, 367 | "metadata": {}, 368 | "outputs": [ 369 | { 370 | "name": "stdout", 371 | "output_type": "stream", 372 | "text": [ 373 | "Harshit is a data scientist!\n" 374 | ] 375 | } 376 | ], 377 | "source": [ 378 | "name = \"Harshit\"\n", 379 | "print(\"%s is a data scientist!\" %name)" 380 | ] 381 | }, 382 | { 383 | "cell_type": "code", 384 | "execution_count": 40, 385 | "metadata": {}, 386 | "outputs": [ 387 | { 388 | "data": { 389 | "text/plain": [ 390 | "'HARSHIT'" 391 | ] 392 | }, 393 | "execution_count": 40, 394 | "metadata": {}, 395 | "output_type": "execute_result" 396 | } 397 | ], 398 | "source": [ 399 | "name.upper()" 400 | ] 401 | }, 402 | { 403 | "cell_type": "code", 404 | "execution_count": 41, 405 | "metadata": {}, 406 | "outputs": [ 407 | { 408 | "data": { 409 | "text/plain": [ 410 | "'harshit'" 411 | ] 412 | }, 413 | "execution_count": 41, 414 | "metadata": {}, 415 | "output_type": "execute_result" 416 | } 417 | ], 418 | "source": [ 419 | "name.lower()" 420 | ] 421 | }, 422 | { 423 | "cell_type": "code", 424 | "execution_count": 42, 425 | "metadata": {}, 426 | "outputs": [ 427 | { 428 | "data": { 429 | "text/plain": [ 430 | "'It is a nice day today.'" 431 | ] 432 | }, 433 | "execution_count": 42, 434 | "metadata": {}, 435 | "output_type": "execute_result" 436 | } 437 | ], 438 | "source": [ 439 | "nstr = \"it is a nice day today.\"\n", 440 | "nstr.capitalize()" 441 | ] 442 | }, 443 | { 444 | "cell_type": "code", 445 | "execution_count": 44, 446 | "metadata": {}, 447 | "outputs": [ 448 | { 449 | "data": { 450 | "text/plain": [ 451 | "3" 452 | ] 453 | }, 454 | "execution_count": 44, 455 | "metadata": {}, 456 | "output_type": "execute_result" 457 | } 458 | ], 459 | "source": [ 460 | "name.index('s')" 461 | ] 462 | }, 463 | { 464 | "cell_type": "code", 465 | "execution_count": 45, 466 | "metadata": {}, 467 | "outputs": [ 468 | { 469 | "data": { 470 | "text/plain": [ 471 | "'rsh'" 472 | ] 473 | }, 474 | "execution_count": 45, 475 | "metadata": {}, 476 | "output_type": "execute_result" 477 | } 478 | ], 479 | "source": [ 480 | "name[2:5]" 481 | ] 482 | }, 483 | { 484 | "cell_type": "code", 485 | "execution_count": 46, 486 | "metadata": {}, 487 | "outputs": [ 488 | { 489 | "data": { 490 | "text/plain": [ 491 | "'rh'" 492 | ] 493 | }, 494 | "execution_count": 46, 495 | "metadata": {}, 496 | "output_type": "execute_result" 497 | } 498 | ], 499 | "source": [ 500 | "name[2:6:2]" 501 | ] 502 | }, 503 | { 504 | "cell_type": "code", 505 | "execution_count": 47, 506 | "metadata": {}, 507 | "outputs": [ 508 | { 509 | "name": "stdout", 510 | "output_type": "stream", 511 | "text": [ 512 | "[3, 4, 5]\n" 513 | ] 514 | } 515 | ], 516 | "source": [ 517 | "alist = [3,4,5]\n", 518 | "print(alist)" 519 | ] 520 | }, 521 | { 522 | "cell_type": "code", 523 | "execution_count": 48, 524 | "metadata": {}, 525 | "outputs": [ 526 | { 527 | "name": "stdout", 528 | "output_type": "stream", 529 | "text": [ 530 | "['harshit', 2, 5.5]\n" 531 | ] 532 | } 533 | ], 534 | "source": [ 535 | "alist = ['harshit', 2, 5.5]\n", 536 | "print(alist)" 537 | ] 538 | }, 539 | { 540 | "cell_type": "code", 541 | "execution_count": 49, 542 | "metadata": {}, 543 | "outputs": [ 544 | { 545 | "name": "stdout", 546 | "output_type": "stream", 547 | "text": [ 548 | "['harshit', 2, 5.5, 10, 15]\n" 549 | ] 550 | } 551 | ], 552 | "source": [ 553 | "alist.append(10)\n", 554 | "alist.append(15)\n", 555 | "print(alist)" 556 | ] 557 | }, 558 | { 559 | "cell_type": "code", 560 | "execution_count": 50, 561 | "metadata": {}, 562 | "outputs": [ 563 | { 564 | "name": "stdout", 565 | "output_type": "stream", 566 | "text": [ 567 | "['harshit', 2, 5.5, 10]\n" 568 | ] 569 | } 570 | ], 571 | "source": [ 572 | "alist.pop()\n", 573 | "print(alist)" 574 | ] 575 | }, 576 | { 577 | "cell_type": "code", 578 | "execution_count": 53, 579 | "metadata": {}, 580 | "outputs": [ 581 | { 582 | "data": { 583 | "text/plain": [ 584 | "10" 585 | ] 586 | }, 587 | "execution_count": 53, 588 | "metadata": {}, 589 | "output_type": "execute_result" 590 | } 591 | ], 592 | "source": [ 593 | "alist[3]" 594 | ] 595 | }, 596 | { 597 | "cell_type": "code", 598 | "execution_count": 54, 599 | "metadata": {}, 600 | "outputs": [ 601 | { 602 | "data": { 603 | "text/plain": [ 604 | "[2, 5.5, 10]" 605 | ] 606 | }, 607 | "execution_count": 54, 608 | "metadata": {}, 609 | "output_type": "execute_result" 610 | } 611 | ], 612 | "source": [ 613 | "alist[1:]" 614 | ] 615 | }, 616 | { 617 | "cell_type": "code", 618 | "execution_count": 55, 619 | "metadata": {}, 620 | "outputs": [ 621 | { 622 | "name": "stdout", 623 | "output_type": "stream", 624 | "text": [ 625 | "['harshit', 2, 5.5, 10, [1, 2, 3]]\n" 626 | ] 627 | } 628 | ], 629 | "source": [ 630 | "alist.append([1,2,3])\n", 631 | "print(alist)" 632 | ] 633 | }, 634 | { 635 | "cell_type": "code", 636 | "execution_count": 56, 637 | "metadata": {}, 638 | "outputs": [ 639 | { 640 | "data": { 641 | "text/plain": [ 642 | "['harshit', 2, 5.5, 10, [1, 2, 3], 'harshit', 2, 5.5, 10, [1, 2, 3]]" 643 | ] 644 | }, 645 | "execution_count": 56, 646 | "metadata": {}, 647 | "output_type": "execute_result" 648 | } 649 | ], 650 | "source": [ 651 | "alist*2" 652 | ] 653 | }, 654 | { 655 | "cell_type": "code", 656 | "execution_count": 57, 657 | "metadata": {}, 658 | "outputs": [ 659 | { 660 | "data": { 661 | "text/plain": [ 662 | "['harshit', 2, 5.5, 10, [1, 2, 3], 'harshit', 2, 5.5, 10, [1, 2, 3]]" 663 | ] 664 | }, 665 | "execution_count": 57, 666 | "metadata": {}, 667 | "output_type": "execute_result" 668 | } 669 | ], 670 | "source": [ 671 | "alist + alist" 672 | ] 673 | }, 674 | { 675 | "cell_type": "code", 676 | "execution_count": null, 677 | "metadata": {}, 678 | "outputs": [], 679 | "source": [] 680 | } 681 | ], 682 | "metadata": { 683 | "kernelspec": { 684 | "display_name": "Python 3", 685 | "language": "python", 686 | "name": "python3" 687 | }, 688 | "language_info": { 689 | "codemirror_mode": { 690 | "name": "ipython", 691 | "version": 3 692 | }, 693 | "file_extension": ".py", 694 | "mimetype": "text/x-python", 695 | "name": "python", 696 | "nbconvert_exporter": "python", 697 | "pygments_lexer": "ipython3", 698 | "version": "3.7.4" 699 | } 700 | }, 701 | "nbformat": 4, 702 | "nbformat_minor": 4 703 | } 704 | -------------------------------------------------------------------------------- /Notebooks/python_fundamentals_part-2.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Python Fundamentals - part II\n", 8 | "\n", 9 | "The notebook intends to cover the following topics:\n", 10 | "1. Lists\n", 11 | "2. Tuples\n", 12 | "3. Dictionaries\n", 13 | "4. Comprehension constructs\n", 14 | "5. Functions in Python" 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": 1, 20 | "metadata": {}, 21 | "outputs": [], 22 | "source": [ 23 | "alist = ['Tom', 54, 'Julia', 78]" 24 | ] 25 | }, 26 | { 27 | "cell_type": "code", 28 | "execution_count": 2, 29 | "metadata": {}, 30 | "outputs": [ 31 | { 32 | "data": { 33 | "text/plain": [ 34 | "['Tom', 54, 'Julia', 78]" 35 | ] 36 | }, 37 | "execution_count": 2, 38 | "metadata": {}, 39 | "output_type": "execute_result" 40 | } 41 | ], 42 | "source": [ 43 | "alist" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": 3, 49 | "metadata": {}, 50 | "outputs": [], 51 | "source": [ 52 | "alist.append(help)" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": 4, 58 | "metadata": {}, 59 | "outputs": [ 60 | { 61 | "data": { 62 | "text/plain": [ 63 | "['Tom',\n", 64 | " 54,\n", 65 | " 'Julia',\n", 66 | " 78,\n", 67 | " Type help() for interactive help, or help(object) for help about object.]" 68 | ] 69 | }, 70 | "execution_count": 4, 71 | "metadata": {}, 72 | "output_type": "execute_result" 73 | } 74 | ], 75 | "source": [ 76 | "alist" 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "execution_count": 5, 82 | "metadata": {}, 83 | "outputs": [ 84 | { 85 | "name": "stdout", 86 | "output_type": "stream", 87 | "text": [ 88 | "\n", 89 | "Welcome to Python 3.7's help utility!\n", 90 | "\n", 91 | "If this is your first time using Python, you should definitely check out\n", 92 | "the tutorial on the Internet at https://docs.python.org/3.7/tutorial/.\n", 93 | "\n", 94 | "Enter the name of any module, keyword, or topic to get help on writing\n", 95 | "Python programs and using Python modules. To quit this help utility and\n", 96 | "return to the interpreter, just type \"quit\".\n", 97 | "\n", 98 | "To get a list of available modules, keywords, symbols, or topics, type\n", 99 | "\"modules\", \"keywords\", \"symbols\", or \"topics\". Each module also comes\n", 100 | "with a one-line summary of what it does; to list the modules whose name\n", 101 | "or summary contain a given string such as \"spam\", type \"modules spam\".\n", 102 | "\n", 103 | "help> sum\n", 104 | "Help on built-in function sum in module builtins:\n", 105 | "\n", 106 | "sum(iterable, start=0, /)\n", 107 | " Return the sum of a 'start' value (default: 0) plus an iterable of numbers\n", 108 | " \n", 109 | " When the iterable is empty, return the start value.\n", 110 | " This function is intended specifically for use with numeric values and may\n", 111 | " reject non-numeric types.\n", 112 | "\n", 113 | "help> quit\n", 114 | "\n", 115 | "You are now leaving help and returning to the Python interpreter.\n", 116 | "If you want to ask for help on a particular object directly from the\n", 117 | "interpreter, you can type \"help(object)\". Executing \"help('string')\"\n", 118 | "has the same effect as typing a particular string at the help> prompt.\n" 119 | ] 120 | } 121 | ], 122 | "source": [ 123 | "help()" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": 6, 129 | "metadata": {}, 130 | "outputs": [], 131 | "source": [ 132 | "blists = [\n", 133 | " ['Tom', 54],\n", 134 | " ['Julia', 78]\n", 135 | "]" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": 7, 141 | "metadata": {}, 142 | "outputs": [ 143 | { 144 | "data": { 145 | "text/plain": [ 146 | "[['Tom', 54], ['Julia', 78]]" 147 | ] 148 | }, 149 | "execution_count": 7, 150 | "metadata": {}, 151 | "output_type": "execute_result" 152 | } 153 | ], 154 | "source": [ 155 | "blists" 156 | ] 157 | }, 158 | { 159 | "cell_type": "code", 160 | "execution_count": 12, 161 | "metadata": {}, 162 | "outputs": [ 163 | { 164 | "data": { 165 | "text/plain": [ 166 | "['Julia', 78]" 167 | ] 168 | }, 169 | "execution_count": 12, 170 | "metadata": {}, 171 | "output_type": "execute_result" 172 | } 173 | ], 174 | "source": [ 175 | "blists[-1]" 176 | ] 177 | }, 178 | { 179 | "cell_type": "code", 180 | "execution_count": 13, 181 | "metadata": {}, 182 | "outputs": [ 183 | { 184 | "data": { 185 | "text/plain": [ 186 | "'Tom'" 187 | ] 188 | }, 189 | "execution_count": 13, 190 | "metadata": {}, 191 | "output_type": "execute_result" 192 | } 193 | ], 194 | "source": [ 195 | "blists[-2][0]" 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": 14, 201 | "metadata": {}, 202 | "outputs": [ 203 | { 204 | "data": { 205 | "text/plain": [ 206 | "[['Tom', 54], ['Julia', 78], ['Mak', 90]]" 207 | ] 208 | }, 209 | "execution_count": 14, 210 | "metadata": {}, 211 | "output_type": "execute_result" 212 | } 213 | ], 214 | "source": [ 215 | "blists.append(['Mak', 90])\n", 216 | "blists" 217 | ] 218 | }, 219 | { 220 | "cell_type": "code", 221 | "execution_count": 15, 222 | "metadata": {}, 223 | "outputs": [ 224 | { 225 | "data": { 226 | "text/plain": [ 227 | "[0, 0, 0, 0, 0]" 228 | ] 229 | }, 230 | "execution_count": 15, 231 | "metadata": {}, 232 | "output_type": "execute_result" 233 | } 234 | ], 235 | "source": [ 236 | "a = [0]*5\n", 237 | "a" 238 | ] 239 | }, 240 | { 241 | "cell_type": "code", 242 | "execution_count": 16, 243 | "metadata": {}, 244 | "outputs": [], 245 | "source": [ 246 | "a = [[0]*cols]*rows" 247 | ] 248 | }, 249 | { 250 | "cell_type": "code", 251 | "execution_count": 18, 252 | "metadata": {}, 253 | "outputs": [], 254 | "source": [ 255 | "cols = 5\n", 256 | "rows = 4\n", 257 | "dlist = [[1]*cols]*rows" 258 | ] 259 | }, 260 | { 261 | "cell_type": "code", 262 | "execution_count": 19, 263 | "metadata": {}, 264 | "outputs": [ 265 | { 266 | "data": { 267 | "text/plain": [ 268 | "[[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]" 269 | ] 270 | }, 271 | "execution_count": 19, 272 | "metadata": {}, 273 | "output_type": "execute_result" 274 | } 275 | ], 276 | "source": [ 277 | "dlist" 278 | ] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "execution_count": 23, 283 | "metadata": {}, 284 | "outputs": [ 285 | { 286 | "ename": "TypeError", 287 | "evalue": "'tuple' object does not support item assignment", 288 | "output_type": "error", 289 | "traceback": [ 290 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 291 | "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", 292 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# tuples\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mtup1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m'Tom'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m78\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mtup1\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m90\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 293 | "\u001b[0;31mTypeError\u001b[0m: 'tuple' object does not support item assignment" 294 | ] 295 | } 296 | ], 297 | "source": [ 298 | "# tuples\n", 299 | "tup1 = ('Tom', 78)\n", 300 | "tup1[1] = 90" 301 | ] 302 | }, 303 | { 304 | "cell_type": "code", 305 | "execution_count": 24, 306 | "metadata": {}, 307 | "outputs": [ 308 | { 309 | "data": { 310 | "text/plain": [ 311 | "('Tom', 78, 'Julia', 89)" 312 | ] 313 | }, 314 | "execution_count": 24, 315 | "metadata": {}, 316 | "output_type": "execute_result" 317 | } 318 | ], 319 | "source": [ 320 | "tup2 = ('Julia', 89)\n", 321 | "tup1 + tup2" 322 | ] 323 | }, 324 | { 325 | "cell_type": "code", 326 | "execution_count": 25, 327 | "metadata": {}, 328 | "outputs": [ 329 | { 330 | "data": { 331 | "text/plain": [ 332 | "('Tom', 78)" 333 | ] 334 | }, 335 | "execution_count": 25, 336 | "metadata": {}, 337 | "output_type": "execute_result" 338 | } 339 | ], 340 | "source": [ 341 | "tup1" 342 | ] 343 | }, 344 | { 345 | "cell_type": "code", 346 | "execution_count": 26, 347 | "metadata": {}, 348 | "outputs": [], 349 | "source": [ 350 | "tup3 = tup1 + tup2" 351 | ] 352 | }, 353 | { 354 | "cell_type": "code", 355 | "execution_count": 27, 356 | "metadata": {}, 357 | "outputs": [ 358 | { 359 | "data": { 360 | "text/plain": [ 361 | "('Tom', 78, 'Julia', 89)" 362 | ] 363 | }, 364 | "execution_count": 27, 365 | "metadata": {}, 366 | "output_type": "execute_result" 367 | } 368 | ], 369 | "source": [ 370 | "tup3" 371 | ] 372 | }, 373 | { 374 | "cell_type": "code", 375 | "execution_count": 28, 376 | "metadata": {}, 377 | "outputs": [ 378 | { 379 | "data": { 380 | "text/plain": [ 381 | "4" 382 | ] 383 | }, 384 | "execution_count": 28, 385 | "metadata": {}, 386 | "output_type": "execute_result" 387 | } 388 | ], 389 | "source": [ 390 | "len(tup3)" 391 | ] 392 | }, 393 | { 394 | "cell_type": "code", 395 | "execution_count": 29, 396 | "metadata": {}, 397 | "outputs": [ 398 | { 399 | "name": "stdout", 400 | "output_type": "stream", 401 | "text": [ 402 | "{'India': 1, 'USA': 2, 'China': 3}\n" 403 | ] 404 | } 405 | ], 406 | "source": [ 407 | "# dictionary\n", 408 | "country_code = {'India': 1, 'USA': 2, 'China': 3}\n", 409 | "print(country_code)" 410 | ] 411 | }, 412 | { 413 | "cell_type": "code", 414 | "execution_count": 30, 415 | "metadata": {}, 416 | "outputs": [ 417 | { 418 | "name": "stdout", 419 | "output_type": "stream", 420 | "text": [ 421 | "3\n" 422 | ] 423 | } 424 | ], 425 | "source": [ 426 | "print(country_code['China'])" 427 | ] 428 | }, 429 | { 430 | "cell_type": "code", 431 | "execution_count": 31, 432 | "metadata": {}, 433 | "outputs": [ 434 | { 435 | "name": "stdout", 436 | "output_type": "stream", 437 | "text": [ 438 | "{'India': 1, 'USA': 2, 'China': 3, 'UAE': 4}\n" 439 | ] 440 | } 441 | ], 442 | "source": [ 443 | "country_code['UAE'] = 4\n", 444 | "print(country_code)" 445 | ] 446 | }, 447 | { 448 | "cell_type": "code", 449 | "execution_count": 33, 450 | "metadata": {}, 451 | "outputs": [ 452 | { 453 | "data": { 454 | "text/plain": [ 455 | "False" 456 | ] 457 | }, 458 | "execution_count": 33, 459 | "metadata": {}, 460 | "output_type": "execute_result" 461 | } 462 | ], 463 | "source": [ 464 | "'Inda' in country_code" 465 | ] 466 | }, 467 | { 468 | "cell_type": "code", 469 | "execution_count": 34, 470 | "metadata": {}, 471 | "outputs": [ 472 | { 473 | "data": { 474 | "text/plain": [ 475 | "bool" 476 | ] 477 | }, 478 | "execution_count": 34, 479 | "metadata": {}, 480 | "output_type": "execute_result" 481 | } 482 | ], 483 | "source": [ 484 | "x = True\n", 485 | "type(x)" 486 | ] 487 | }, 488 | { 489 | "cell_type": "code", 490 | "execution_count": 35, 491 | "metadata": {}, 492 | "outputs": [ 493 | { 494 | "data": { 495 | "text/plain": [ 496 | "False" 497 | ] 498 | }, 499 | "execution_count": 35, 500 | "metadata": {}, 501 | "output_type": "execute_result" 502 | } 503 | ], 504 | "source": [ 505 | "1 == 2" 506 | ] 507 | }, 508 | { 509 | "cell_type": "code", 510 | "execution_count": 36, 511 | "metadata": {}, 512 | "outputs": [ 513 | { 514 | "data": { 515 | "text/plain": [ 516 | "True" 517 | ] 518 | }, 519 | "execution_count": 36, 520 | "metadata": {}, 521 | "output_type": "execute_result" 522 | } 523 | ], 524 | "source": [ 525 | "1 != 2" 526 | ] 527 | }, 528 | { 529 | "cell_type": "code", 530 | "execution_count": 38, 531 | "metadata": {}, 532 | "outputs": [ 533 | { 534 | "name": "stdout", 535 | "output_type": "stream", 536 | "text": [ 537 | "False\n", 538 | "False\n", 539 | "True\n", 540 | "True\n" 541 | ] 542 | } 543 | ], 544 | "source": [ 545 | "a = 1\n", 546 | "b = 2\n", 547 | "print(a == b)\n", 548 | "print(a > b)\n", 549 | "print(a < b)\n", 550 | "print(a != b)" 551 | ] 552 | }, 553 | { 554 | "cell_type": "code", 555 | "execution_count": 39, 556 | "metadata": {}, 557 | "outputs": [ 558 | { 559 | "name": "stdout", 560 | "output_type": "stream", 561 | "text": [ 562 | "Color is red!\n", 563 | "Color problem is solved!!\n" 564 | ] 565 | } 566 | ], 567 | "source": [ 568 | "color = 'red'\n", 569 | "if color == 'red':\n", 570 | " print(\"Color is red!\")\n", 571 | " \n", 572 | "print(\"Color problem is solved!!\")" 573 | ] 574 | }, 575 | { 576 | "cell_type": "code", 577 | "execution_count": 42, 578 | "metadata": {}, 579 | "outputs": [ 580 | { 581 | "name": "stdout", 582 | "output_type": "stream", 583 | "text": [ 584 | "color is not red!\n", 585 | "Color problem is solved!!\n" 586 | ] 587 | } 588 | ], 589 | "source": [ 590 | "color = 'kjh'\n", 591 | "if color == 'red':\n", 592 | " print(\"Color is red!\")\n", 593 | " \n", 594 | "else:\n", 595 | " print(\"color is not red!\")\n", 596 | " \n", 597 | "print(\"Color problem is solved!!\")" 598 | ] 599 | }, 600 | { 601 | "cell_type": "code", 602 | "execution_count": 43, 603 | "metadata": {}, 604 | "outputs": [ 605 | { 606 | "name": "stdout", 607 | "output_type": "stream", 608 | "text": [ 609 | "Color is green!\n", 610 | "Color problem is solved!!\n" 611 | ] 612 | } 613 | ], 614 | "source": [ 615 | "color = 'green'\n", 616 | "if color == 'red':\n", 617 | " print(\"Color is red!\")\n", 618 | " \n", 619 | "elif color == 'green':\n", 620 | " print(\"Color is green!\")\n", 621 | " \n", 622 | "else:\n", 623 | " print(\"color is not red!\")\n", 624 | " \n", 625 | "print(\"Color problem is solved!!\")" 626 | ] 627 | }, 628 | { 629 | "cell_type": "code", 630 | "execution_count": 44, 631 | "metadata": {}, 632 | "outputs": [ 633 | { 634 | "name": "stdout", 635 | "output_type": "stream", 636 | "text": [ 637 | "Juvenile\n" 638 | ] 639 | } 640 | ], 641 | "source": [ 642 | "age = 15\n", 643 | "if age >= 18:\n", 644 | " print(\"Adult\")\n", 645 | " \n", 646 | "else:\n", 647 | " print(\"Juvenile\")" 648 | ] 649 | }, 650 | { 651 | "cell_type": "code", 652 | "execution_count": 45, 653 | "metadata": {}, 654 | "outputs": [ 655 | { 656 | "data": { 657 | "text/plain": [ 658 | "True" 659 | ] 660 | }, 661 | "execution_count": 45, 662 | "metadata": {}, 663 | "output_type": "execute_result" 664 | } 665 | ], 666 | "source": [ 667 | "a = 0\n", 668 | "not(a)" 669 | ] 670 | }, 671 | { 672 | "cell_type": "code", 673 | "execution_count": 46, 674 | "metadata": {}, 675 | "outputs": [ 676 | { 677 | "data": { 678 | "text/plain": [ 679 | "False" 680 | ] 681 | }, 682 | "execution_count": 46, 683 | "metadata": {}, 684 | "output_type": "execute_result" 685 | } 686 | ], 687 | "source": [ 688 | "a = 3\n", 689 | "not(a)" 690 | ] 691 | }, 692 | { 693 | "cell_type": "code", 694 | "execution_count": 47, 695 | "metadata": {}, 696 | "outputs": [ 697 | { 698 | "data": { 699 | "text/plain": [ 700 | "False" 701 | ] 702 | }, 703 | "execution_count": 47, 704 | "metadata": {}, 705 | "output_type": "execute_result" 706 | } 707 | ], 708 | "source": [ 709 | "a = True\n", 710 | "not(a)" 711 | ] 712 | }, 713 | { 714 | "cell_type": "code", 715 | "execution_count": 49, 716 | "metadata": {}, 717 | "outputs": [ 718 | { 719 | "name": "stdout", 720 | "output_type": "stream", 721 | "text": [ 722 | "Try again next year\n" 723 | ] 724 | } 725 | ], 726 | "source": [ 727 | "score = 76\n", 728 | "percentile = 83\n", 729 | "\n", 730 | "if score > 75 or percentile > 90:\n", 731 | " print(\"Admission successful!\")\n", 732 | "else:\n", 733 | " print(\"Try again next year\")\n" 734 | ] 735 | }, 736 | { 737 | "cell_type": "code", 738 | "execution_count": 51, 739 | "metadata": {}, 740 | "outputs": [ 741 | { 742 | "data": { 743 | "text/plain": [ 744 | "range(0, 5)" 745 | ] 746 | }, 747 | "execution_count": 51, 748 | "metadata": {}, 749 | "output_type": "execute_result" 750 | } 751 | ], 752 | "source": [ 753 | "range(5)" 754 | ] 755 | }, 756 | { 757 | "cell_type": "code", 758 | "execution_count": 52, 759 | "metadata": {}, 760 | "outputs": [ 761 | { 762 | "name": "stdout", 763 | "output_type": "stream", 764 | "text": [ 765 | "0\n", 766 | "1\n", 767 | "2\n", 768 | "3\n", 769 | "4\n" 770 | ] 771 | } 772 | ], 773 | "source": [ 774 | "for i in range(5):\n", 775 | " print(i)" 776 | ] 777 | }, 778 | { 779 | "cell_type": "code", 780 | "execution_count": 54, 781 | "metadata": {}, 782 | "outputs": [ 783 | { 784 | "name": "stdout", 785 | "output_type": "stream", 786 | "text": [ 787 | "8\n", 788 | "24\n", 789 | "40\n", 790 | "56\n", 791 | "72\n" 792 | ] 793 | } 794 | ], 795 | "source": [ 796 | "for i in range(1, 10, 2):\n", 797 | " product = 8 * i\n", 798 | " print(product)" 799 | ] 800 | }, 801 | { 802 | "cell_type": "code", 803 | "execution_count": 55, 804 | "metadata": {}, 805 | "outputs": [ 806 | { 807 | "name": "stdout", 808 | "output_type": "stream", 809 | "text": [ 810 | "HARSHIT\n", 811 | "SHUBHAM\n", 812 | "SAHIL\n" 813 | ] 814 | } 815 | ], 816 | "source": [ 817 | "names = ('harshit', 'shubham', 'sahil')\n", 818 | "for name in names:\n", 819 | " print(name.upper())" 820 | ] 821 | }, 822 | { 823 | "cell_type": "code", 824 | "execution_count": 56, 825 | "metadata": {}, 826 | "outputs": [ 827 | { 828 | "name": "stdout", 829 | "output_type": "stream", 830 | "text": [ 831 | "Juvenile\n", 832 | "Adult\n", 833 | "Adult\n", 834 | "Juvenile\n" 835 | ] 836 | } 837 | ], 838 | "source": [ 839 | "age = [12,43,45,10]\n", 840 | "i = 0\n", 841 | "while i < len(age):\n", 842 | " if age[i] >= 18:\n", 843 | " print(\"Adult\")\n", 844 | " else:\n", 845 | " print(\"Juvenile\")\n", 846 | " i += 1" 847 | ] 848 | }, 849 | { 850 | "cell_type": "code", 851 | "execution_count": 57, 852 | "metadata": {}, 853 | "outputs": [ 854 | { 855 | "name": "stdout", 856 | "output_type": "stream", 857 | "text": [ 858 | "[1, 8, 27, 64, 125, 216, 343, 512, 729]\n" 859 | ] 860 | } 861 | ], 862 | "source": [ 863 | "# list comprehension\n", 864 | "\n", 865 | "cubes = [n** 3 for n in range(1,10)]\n", 866 | "print(cubes)" 867 | ] 868 | }, 869 | { 870 | "cell_type": "code", 871 | "execution_count": 58, 872 | "metadata": {}, 873 | "outputs": [ 874 | { 875 | "name": "stdout", 876 | "output_type": "stream", 877 | "text": [ 878 | "[1, 8, 27, 64, 125, 216, 343, 512, 729]\n" 879 | ] 880 | } 881 | ], 882 | "source": [ 883 | "cubes = []\n", 884 | "for i in range(1,10):\n", 885 | " cubes.append(i ** 3)\n", 886 | "print(cubes)" 887 | ] 888 | }, 889 | { 890 | "cell_type": "code", 891 | "execution_count": 62, 892 | "metadata": {}, 893 | "outputs": [ 894 | { 895 | "name": "stdout", 896 | "output_type": "stream", 897 | "text": [ 898 | "Help on built-in function abs in module builtins:\n", 899 | "\n", 900 | "abs(x, /)\n", 901 | " Return the absolute value of the argument.\n", 902 | "\n" 903 | ] 904 | } 905 | ], 906 | "source": [ 907 | "help(abs)" 908 | ] 909 | }, 910 | { 911 | "cell_type": "code", 912 | "execution_count": 64, 913 | "metadata": {}, 914 | "outputs": [ 915 | { 916 | "data": { 917 | "text/plain": [ 918 | "3" 919 | ] 920 | }, 921 | "execution_count": 64, 922 | "metadata": {}, 923 | "output_type": "execute_result" 924 | } 925 | ], 926 | "source": [ 927 | "abs(2-5)" 928 | ] 929 | }, 930 | { 931 | "cell_type": "code", 932 | "execution_count": 65, 933 | "metadata": {}, 934 | "outputs": [], 935 | "source": [ 936 | "def add_two_numbers(a, b):\n", 937 | " sum = a + b\n", 938 | " return sum" 939 | ] 940 | }, 941 | { 942 | "cell_type": "code", 943 | "execution_count": 66, 944 | "metadata": {}, 945 | "outputs": [ 946 | { 947 | "data": { 948 | "text/plain": [ 949 | "16" 950 | ] 951 | }, 952 | "execution_count": 66, 953 | "metadata": {}, 954 | "output_type": "execute_result" 955 | } 956 | ], 957 | "source": [ 958 | "add_two_numbers(5,11)" 959 | ] 960 | }, 961 | { 962 | "cell_type": "code", 963 | "execution_count": 67, 964 | "metadata": {}, 965 | "outputs": [], 966 | "source": [ 967 | "def fahr_to_celsius(temp):\n", 968 | " \"\"\"\n", 969 | " This function converts temperature from fahrenheit\n", 970 | " to celsius.\n", 971 | " Args:\n", 972 | " -----\n", 973 | " tempInFahr: temperature in fahrenheit\n", 974 | "\n", 975 | " Returns:\n", 976 | " --------\n", 977 | " tempInCel: temperature in celsius\n", 978 | " \"\"\"\n", 979 | " tempInCel = (temp - 32) * 5/9\n", 980 | " return tempInCel\n", 981 | " " 982 | ] 983 | }, 984 | { 985 | "cell_type": "code", 986 | "execution_count": 68, 987 | "metadata": {}, 988 | "outputs": [ 989 | { 990 | "data": { 991 | "text/plain": [ 992 | "10.0" 993 | ] 994 | }, 995 | "execution_count": 68, 996 | "metadata": {}, 997 | "output_type": "execute_result" 998 | } 999 | ], 1000 | "source": [ 1001 | "fahr_to_celsius(50)" 1002 | ] 1003 | }, 1004 | { 1005 | "cell_type": "code", 1006 | "execution_count": null, 1007 | "metadata": {}, 1008 | "outputs": [], 1009 | "source": [] 1010 | } 1011 | ], 1012 | "metadata": { 1013 | "kernelspec": { 1014 | "display_name": "Python 3", 1015 | "language": "python", 1016 | "name": "python3" 1017 | }, 1018 | "language_info": { 1019 | "codemirror_mode": { 1020 | "name": "ipython", 1021 | "version": 3 1022 | }, 1023 | "file_extension": ".py", 1024 | "mimetype": "text/x-python", 1025 | "name": "python", 1026 | "nbconvert_exporter": "python", 1027 | "pygments_lexer": "ipython3", 1028 | "version": "3.7.4" 1029 | } 1030 | }, 1031 | "nbformat": 4, 1032 | "nbformat_minor": 4 1033 | } 1034 | -------------------------------------------------------------------------------- /Notebooks/python_fundamentals_part-3.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Python Fundamentals - part II\n", 8 | "\n", 9 | "The notebook intends to cover the following topics:\n", 10 | "1. List class functions\n", 11 | "2. Object oriented programming\n", 12 | "3. Creating our own classes\n", 13 | "4. Working with external libraries." 14 | ] 15 | }, 16 | { 17 | "cell_type": "code", 18 | "execution_count": 1, 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "a = 5" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": 2, 28 | "metadata": {}, 29 | "outputs": [ 30 | { 31 | "name": "stdout", 32 | "output_type": "stream", 33 | "text": [ 34 | "\n" 35 | ] 36 | } 37 | ], 38 | "source": [ 39 | "print(type(a))" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": 3, 45 | "metadata": {}, 46 | "outputs": [ 47 | { 48 | "name": "stdout", 49 | "output_type": "stream", 50 | "text": [ 51 | "\n" 52 | ] 53 | } 54 | ], 55 | "source": [ 56 | "alist = [1,2,'a']\n", 57 | "print(type(alist))" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": 4, 63 | "metadata": {}, 64 | "outputs": [ 65 | { 66 | "name": "stdout", 67 | "output_type": "stream", 68 | "text": [ 69 | "[3, 4, 5, 5, 6, 7]\n" 70 | ] 71 | } 72 | ], 73 | "source": [ 74 | "heights = [5,4,6,7,3,5]\n", 75 | "heights.sort()\n", 76 | "print(heights)" 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "execution_count": 5, 82 | "metadata": {}, 83 | "outputs": [ 84 | { 85 | "name": "stdout", 86 | "output_type": "stream", 87 | "text": [ 88 | "['a', 2, 1]\n" 89 | ] 90 | } 91 | ], 92 | "source": [ 93 | "alist.reverse()\n", 94 | "print(alist)" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "execution_count": 6, 100 | "metadata": {}, 101 | "outputs": [], 102 | "source": [ 103 | "astring = 'hello world'\n", 104 | "bstring = astring.replace('world', 'there!')" 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "execution_count": 7, 110 | "metadata": {}, 111 | "outputs": [ 112 | { 113 | "name": "stdout", 114 | "output_type": "stream", 115 | "text": [ 116 | "hello there!\n" 117 | ] 118 | } 119 | ], 120 | "source": [ 121 | "print(bstring)" 122 | ] 123 | }, 124 | { 125 | "cell_type": "code", 126 | "execution_count": 8, 127 | "metadata": {}, 128 | "outputs": [ 129 | { 130 | "data": { 131 | "text/plain": [ 132 | "['__add__',\n", 133 | " '__class__',\n", 134 | " '__contains__',\n", 135 | " '__delattr__',\n", 136 | " '__delitem__',\n", 137 | " '__dir__',\n", 138 | " '__doc__',\n", 139 | " '__eq__',\n", 140 | " '__format__',\n", 141 | " '__ge__',\n", 142 | " '__getattribute__',\n", 143 | " '__getitem__',\n", 144 | " '__gt__',\n", 145 | " '__hash__',\n", 146 | " '__iadd__',\n", 147 | " '__imul__',\n", 148 | " '__init__',\n", 149 | " '__init_subclass__',\n", 150 | " '__iter__',\n", 151 | " '__le__',\n", 152 | " '__len__',\n", 153 | " '__lt__',\n", 154 | " '__mul__',\n", 155 | " '__ne__',\n", 156 | " '__new__',\n", 157 | " '__reduce__',\n", 158 | " '__reduce_ex__',\n", 159 | " '__repr__',\n", 160 | " '__reversed__',\n", 161 | " '__rmul__',\n", 162 | " '__setattr__',\n", 163 | " '__setitem__',\n", 164 | " '__sizeof__',\n", 165 | " '__str__',\n", 166 | " '__subclasshook__',\n", 167 | " 'append',\n", 168 | " 'clear',\n", 169 | " 'copy',\n", 170 | " 'count',\n", 171 | " 'extend',\n", 172 | " 'index',\n", 173 | " 'insert',\n", 174 | " 'pop',\n", 175 | " 'remove',\n", 176 | " 'reverse',\n", 177 | " 'sort']" 178 | ] 179 | }, 180 | "execution_count": 8, 181 | "metadata": {}, 182 | "output_type": "execute_result" 183 | } 184 | ], 185 | "source": [ 186 | "dir(alist)" 187 | ] 188 | }, 189 | { 190 | "cell_type": "code", 191 | "execution_count": 9, 192 | "metadata": {}, 193 | "outputs": [], 194 | "source": [ 195 | "class Rectangle:\n", 196 | " \n", 197 | " def __init__(self, height, width):\n", 198 | " self.height = height\n", 199 | " self.width = width\n", 200 | " \n", 201 | " def area(self):\n", 202 | " area = self.height * self.width\n", 203 | " return area" 204 | ] 205 | }, 206 | { 207 | "cell_type": "code", 208 | "execution_count": 10, 209 | "metadata": {}, 210 | "outputs": [], 211 | "source": [ 212 | "rect1 = Rectangle(12, 10)" 213 | ] 214 | }, 215 | { 216 | "cell_type": "code", 217 | "execution_count": 11, 218 | "metadata": {}, 219 | "outputs": [ 220 | { 221 | "name": "stdout", 222 | "output_type": "stream", 223 | "text": [ 224 | "\n" 225 | ] 226 | } 227 | ], 228 | "source": [ 229 | "print(type(rect1))" 230 | ] 231 | }, 232 | { 233 | "cell_type": "code", 234 | "execution_count": 12, 235 | "metadata": {}, 236 | "outputs": [ 237 | { 238 | "data": { 239 | "text/plain": [ 240 | "12" 241 | ] 242 | }, 243 | "execution_count": 12, 244 | "metadata": {}, 245 | "output_type": "execute_result" 246 | } 247 | ], 248 | "source": [ 249 | "rect1.height" 250 | ] 251 | }, 252 | { 253 | "cell_type": "code", 254 | "execution_count": 13, 255 | "metadata": {}, 256 | "outputs": [ 257 | { 258 | "data": { 259 | "text/plain": [ 260 | "10" 261 | ] 262 | }, 263 | "execution_count": 13, 264 | "metadata": {}, 265 | "output_type": "execute_result" 266 | } 267 | ], 268 | "source": [ 269 | "rect1.width" 270 | ] 271 | }, 272 | { 273 | "cell_type": "code", 274 | "execution_count": 14, 275 | "metadata": {}, 276 | "outputs": [ 277 | { 278 | "data": { 279 | "text/plain": [ 280 | "120" 281 | ] 282 | }, 283 | "execution_count": 14, 284 | "metadata": {}, 285 | "output_type": "execute_result" 286 | } 287 | ], 288 | "source": [ 289 | "rect1.area()" 290 | ] 291 | }, 292 | { 293 | "cell_type": "code", 294 | "execution_count": 15, 295 | "metadata": {}, 296 | "outputs": [ 297 | { 298 | "data": { 299 | "text/plain": [ 300 | "['__class__',\n", 301 | " '__delattr__',\n", 302 | " '__dict__',\n", 303 | " '__dir__',\n", 304 | " '__doc__',\n", 305 | " '__eq__',\n", 306 | " '__format__',\n", 307 | " '__ge__',\n", 308 | " '__getattribute__',\n", 309 | " '__gt__',\n", 310 | " '__hash__',\n", 311 | " '__init__',\n", 312 | " '__init_subclass__',\n", 313 | " '__le__',\n", 314 | " '__lt__',\n", 315 | " '__module__',\n", 316 | " '__ne__',\n", 317 | " '__new__',\n", 318 | " '__reduce__',\n", 319 | " '__reduce_ex__',\n", 320 | " '__repr__',\n", 321 | " '__setattr__',\n", 322 | " '__sizeof__',\n", 323 | " '__str__',\n", 324 | " '__subclasshook__',\n", 325 | " '__weakref__',\n", 326 | " 'area',\n", 327 | " 'height',\n", 328 | " 'width']" 329 | ] 330 | }, 331 | "execution_count": 15, 332 | "metadata": {}, 333 | "output_type": "execute_result" 334 | } 335 | ], 336 | "source": [ 337 | "dir(rect1)" 338 | ] 339 | }, 340 | { 341 | "cell_type": "code", 342 | "execution_count": 16, 343 | "metadata": {}, 344 | "outputs": [], 345 | "source": [ 346 | "import math" 347 | ] 348 | }, 349 | { 350 | "cell_type": "code", 351 | "execution_count": 17, 352 | "metadata": {}, 353 | "outputs": [ 354 | { 355 | "name": "stdout", 356 | "output_type": "stream", 357 | "text": [ 358 | "\n" 359 | ] 360 | } 361 | ], 362 | "source": [ 363 | "print(type(math))" 364 | ] 365 | }, 366 | { 367 | "cell_type": "code", 368 | "execution_count": 18, 369 | "metadata": {}, 370 | "outputs": [ 371 | { 372 | "data": { 373 | "text/plain": [ 374 | "['__doc__',\n", 375 | " '__file__',\n", 376 | " '__loader__',\n", 377 | " '__name__',\n", 378 | " '__package__',\n", 379 | " '__spec__',\n", 380 | " 'acos',\n", 381 | " 'acosh',\n", 382 | " 'asin',\n", 383 | " 'asinh',\n", 384 | " 'atan',\n", 385 | " 'atan2',\n", 386 | " 'atanh',\n", 387 | " 'ceil',\n", 388 | " 'copysign',\n", 389 | " 'cos',\n", 390 | " 'cosh',\n", 391 | " 'degrees',\n", 392 | " 'e',\n", 393 | " 'erf',\n", 394 | " 'erfc',\n", 395 | " 'exp',\n", 396 | " 'expm1',\n", 397 | " 'fabs',\n", 398 | " 'factorial',\n", 399 | " 'floor',\n", 400 | " 'fmod',\n", 401 | " 'frexp',\n", 402 | " 'fsum',\n", 403 | " 'gamma',\n", 404 | " 'gcd',\n", 405 | " 'hypot',\n", 406 | " 'inf',\n", 407 | " 'isclose',\n", 408 | " 'isfinite',\n", 409 | " 'isinf',\n", 410 | " 'isnan',\n", 411 | " 'ldexp',\n", 412 | " 'lgamma',\n", 413 | " 'log',\n", 414 | " 'log10',\n", 415 | " 'log1p',\n", 416 | " 'log2',\n", 417 | " 'modf',\n", 418 | " 'nan',\n", 419 | " 'pi',\n", 420 | " 'pow',\n", 421 | " 'radians',\n", 422 | " 'remainder',\n", 423 | " 'sin',\n", 424 | " 'sinh',\n", 425 | " 'sqrt',\n", 426 | " 'tan',\n", 427 | " 'tanh',\n", 428 | " 'tau',\n", 429 | " 'trunc']" 430 | ] 431 | }, 432 | "execution_count": 18, 433 | "metadata": {}, 434 | "output_type": "execute_result" 435 | } 436 | ], 437 | "source": [ 438 | "dir(math)" 439 | ] 440 | }, 441 | { 442 | "cell_type": "code", 443 | "execution_count": 19, 444 | "metadata": {}, 445 | "outputs": [ 446 | { 447 | "name": "stdout", 448 | "output_type": "stream", 449 | "text": [ 450 | "Help on module math:\n", 451 | "\n", 452 | "NAME\n", 453 | " math\n", 454 | "\n", 455 | "MODULE REFERENCE\n", 456 | " https://docs.python.org/3.7/library/math\n", 457 | " \n", 458 | " The following documentation is automatically generated from the Python\n", 459 | " source files. It may be incomplete, incorrect or include features that\n", 460 | " are considered implementation detail and may vary between Python\n", 461 | " implementations. When in doubt, consult the module reference at the\n", 462 | " location listed above.\n", 463 | "\n", 464 | "DESCRIPTION\n", 465 | " This module provides access to the mathematical functions\n", 466 | " defined by the C standard.\n", 467 | "\n", 468 | "FUNCTIONS\n", 469 | " acos(x, /)\n", 470 | " Return the arc cosine (measured in radians) of x.\n", 471 | " \n", 472 | " acosh(x, /)\n", 473 | " Return the inverse hyperbolic cosine of x.\n", 474 | " \n", 475 | " asin(x, /)\n", 476 | " Return the arc sine (measured in radians) of x.\n", 477 | " \n", 478 | " asinh(x, /)\n", 479 | " Return the inverse hyperbolic sine of x.\n", 480 | " \n", 481 | " atan(x, /)\n", 482 | " Return the arc tangent (measured in radians) of x.\n", 483 | " \n", 484 | " atan2(y, x, /)\n", 485 | " Return the arc tangent (measured in radians) of y/x.\n", 486 | " \n", 487 | " Unlike atan(y/x), the signs of both x and y are considered.\n", 488 | " \n", 489 | " atanh(x, /)\n", 490 | " Return the inverse hyperbolic tangent of x.\n", 491 | " \n", 492 | " ceil(x, /)\n", 493 | " Return the ceiling of x as an Integral.\n", 494 | " \n", 495 | " This is the smallest integer >= x.\n", 496 | " \n", 497 | " copysign(x, y, /)\n", 498 | " Return a float with the magnitude (absolute value) of x but the sign of y.\n", 499 | " \n", 500 | " On platforms that support signed zeros, copysign(1.0, -0.0)\n", 501 | " returns -1.0.\n", 502 | " \n", 503 | " cos(x, /)\n", 504 | " Return the cosine of x (measured in radians).\n", 505 | " \n", 506 | " cosh(x, /)\n", 507 | " Return the hyperbolic cosine of x.\n", 508 | " \n", 509 | " degrees(x, /)\n", 510 | " Convert angle x from radians to degrees.\n", 511 | " \n", 512 | " erf(x, /)\n", 513 | " Error function at x.\n", 514 | " \n", 515 | " erfc(x, /)\n", 516 | " Complementary error function at x.\n", 517 | " \n", 518 | " exp(x, /)\n", 519 | " Return e raised to the power of x.\n", 520 | " \n", 521 | " expm1(x, /)\n", 522 | " Return exp(x)-1.\n", 523 | " \n", 524 | " This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.\n", 525 | " \n", 526 | " fabs(x, /)\n", 527 | " Return the absolute value of the float x.\n", 528 | " \n", 529 | " factorial(x, /)\n", 530 | " Find x!.\n", 531 | " \n", 532 | " Raise a ValueError if x is negative or non-integral.\n", 533 | " \n", 534 | " floor(x, /)\n", 535 | " Return the floor of x as an Integral.\n", 536 | " \n", 537 | " This is the largest integer <= x.\n", 538 | " \n", 539 | " fmod(x, y, /)\n", 540 | " Return fmod(x, y), according to platform C.\n", 541 | " \n", 542 | " x % y may differ.\n", 543 | " \n", 544 | " frexp(x, /)\n", 545 | " Return the mantissa and exponent of x, as pair (m, e).\n", 546 | " \n", 547 | " m is a float and e is an int, such that x = m * 2.**e.\n", 548 | " If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0.\n", 549 | " \n", 550 | " fsum(seq, /)\n", 551 | " Return an accurate floating point sum of values in the iterable seq.\n", 552 | " \n", 553 | " Assumes IEEE-754 floating point arithmetic.\n", 554 | " \n", 555 | " gamma(x, /)\n", 556 | " Gamma function at x.\n", 557 | " \n", 558 | " gcd(x, y, /)\n", 559 | " greatest common divisor of x and y\n", 560 | " \n", 561 | " hypot(x, y, /)\n", 562 | " Return the Euclidean distance, sqrt(x*x + y*y).\n", 563 | " \n", 564 | " isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0)\n", 565 | " Determine whether two floating point numbers are close in value.\n", 566 | " \n", 567 | " rel_tol\n", 568 | " maximum difference for being considered \"close\", relative to the\n", 569 | " magnitude of the input values\n", 570 | " abs_tol\n", 571 | " maximum difference for being considered \"close\", regardless of the\n", 572 | " magnitude of the input values\n", 573 | " \n", 574 | " Return True if a is close in value to b, and False otherwise.\n", 575 | " \n", 576 | " For the values to be considered close, the difference between them\n", 577 | " must be smaller than at least one of the tolerances.\n", 578 | " \n", 579 | " -inf, inf and NaN behave similarly to the IEEE 754 Standard. That\n", 580 | " is, NaN is not close to anything, even itself. inf and -inf are\n", 581 | " only close to themselves.\n", 582 | " \n", 583 | " isfinite(x, /)\n", 584 | " Return True if x is neither an infinity nor a NaN, and False otherwise.\n", 585 | " \n", 586 | " isinf(x, /)\n", 587 | " Return True if x is a positive or negative infinity, and False otherwise.\n", 588 | " \n", 589 | " isnan(x, /)\n", 590 | " Return True if x is a NaN (not a number), and False otherwise.\n", 591 | " \n", 592 | " ldexp(x, i, /)\n", 593 | " Return x * (2**i).\n", 594 | " \n", 595 | " This is essentially the inverse of frexp().\n", 596 | " \n", 597 | " lgamma(x, /)\n", 598 | " Natural logarithm of absolute value of Gamma function at x.\n", 599 | " \n", 600 | " log(...)\n", 601 | " log(x, [base=math.e])\n", 602 | " Return the logarithm of x to the given base.\n", 603 | " \n", 604 | " If the base not specified, returns the natural logarithm (base e) of x.\n", 605 | " \n", 606 | " log10(x, /)\n", 607 | " Return the base 10 logarithm of x.\n", 608 | " \n", 609 | " log1p(x, /)\n", 610 | " Return the natural logarithm of 1+x (base e).\n", 611 | " \n", 612 | " The result is computed in a way which is accurate for x near zero.\n", 613 | " \n", 614 | " log2(x, /)\n", 615 | " Return the base 2 logarithm of x.\n", 616 | " \n", 617 | " modf(x, /)\n", 618 | " Return the fractional and integer parts of x.\n", 619 | " \n", 620 | " Both results carry the sign of x and are floats.\n", 621 | " \n", 622 | " pow(x, y, /)\n", 623 | " Return x**y (x to the power of y).\n", 624 | " \n", 625 | " radians(x, /)\n", 626 | " Convert angle x from degrees to radians.\n", 627 | " \n", 628 | " remainder(x, y, /)\n", 629 | " Difference between x and the closest integer multiple of y.\n", 630 | " \n", 631 | " Return x - n*y where n*y is the closest integer multiple of y.\n", 632 | " In the case where x is exactly halfway between two multiples of\n", 633 | " y, the nearest even value of n is used. The result is always exact.\n", 634 | " \n", 635 | " sin(x, /)\n", 636 | " Return the sine of x (measured in radians).\n", 637 | " \n", 638 | " sinh(x, /)\n", 639 | " Return the hyperbolic sine of x.\n", 640 | " \n", 641 | " sqrt(x, /)\n", 642 | " Return the square root of x.\n", 643 | " \n", 644 | " tan(x, /)\n", 645 | " Return the tangent of x (measured in radians).\n", 646 | " \n", 647 | " tanh(x, /)\n", 648 | " Return the hyperbolic tangent of x.\n", 649 | " \n", 650 | " trunc(x, /)\n", 651 | " Truncates the Real x to the nearest Integral toward 0.\n", 652 | " \n", 653 | " Uses the __trunc__ magic method.\n", 654 | "\n", 655 | "DATA\n", 656 | " e = 2.718281828459045\n", 657 | " inf = inf\n", 658 | " nan = nan\n", 659 | " pi = 3.141592653589793\n", 660 | " tau = 6.283185307179586\n", 661 | "\n", 662 | "FILE\n", 663 | " /Users/harshit/anaconda3/lib/python3.7/lib-dynload/math.cpython-37m-darwin.so\n", 664 | "\n", 665 | "\n" 666 | ] 667 | } 668 | ], 669 | "source": [ 670 | "help(math)" 671 | ] 672 | }, 673 | { 674 | "cell_type": "code", 675 | "execution_count": 20, 676 | "metadata": {}, 677 | "outputs": [ 678 | { 679 | "data": { 680 | "text/plain": [ 681 | "2.0" 682 | ] 683 | }, 684 | "execution_count": 20, 685 | "metadata": {}, 686 | "output_type": "execute_result" 687 | } 688 | ], 689 | "source": [ 690 | "math.log(100,10)" 691 | ] 692 | }, 693 | { 694 | "cell_type": "code", 695 | "execution_count": 21, 696 | "metadata": {}, 697 | "outputs": [ 698 | { 699 | "data": { 700 | "text/plain": [ 701 | "3.141592653589793" 702 | ] 703 | }, 704 | "execution_count": 21, 705 | "metadata": {}, 706 | "output_type": "execute_result" 707 | } 708 | ], 709 | "source": [ 710 | "math.pi" 711 | ] 712 | }, 713 | { 714 | "cell_type": "code", 715 | "execution_count": 22, 716 | "metadata": {}, 717 | "outputs": [ 718 | { 719 | "data": { 720 | "text/plain": [ 721 | "2.0" 722 | ] 723 | }, 724 | "execution_count": 22, 725 | "metadata": {}, 726 | "output_type": "execute_result" 727 | } 728 | ], 729 | "source": [ 730 | "import math as mt\n", 731 | "\n", 732 | "mt.log(100,10)" 733 | ] 734 | }, 735 | { 736 | "cell_type": "code", 737 | "execution_count": 27, 738 | "metadata": {}, 739 | "outputs": [ 740 | { 741 | "data": { 742 | "text/plain": [ 743 | "2.0" 744 | ] 745 | }, 746 | "execution_count": 27, 747 | "metadata": {}, 748 | "output_type": "execute_result" 749 | } 750 | ], 751 | "source": [ 752 | "from math import log, pi\n", 753 | "from numpy import asarray\n", 754 | "\n", 755 | "log(100,10)" 756 | ] 757 | }, 758 | { 759 | "cell_type": "code", 760 | "execution_count": null, 761 | "metadata": {}, 762 | "outputs": [], 763 | "source": [] 764 | } 765 | ], 766 | "metadata": { 767 | "kernelspec": { 768 | "display_name": "Python 3", 769 | "language": "python", 770 | "name": "python3" 771 | }, 772 | "language_info": { 773 | "codemirror_mode": { 774 | "name": "ipython", 775 | "version": 3 776 | }, 777 | "file_extension": ".py", 778 | "mimetype": "text/x-python", 779 | "name": "python", 780 | "nbconvert_exporter": "python", 781 | "pygments_lexer": "ipython3", 782 | "version": "3.7.4" 783 | } 784 | }, 785 | "nbformat": 4, 786 | "nbformat_minor": 2 787 | } 788 | -------------------------------------------------------------------------------- /Notebooks/python_fundamentals_part_1.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "kernelspec": { 6 | "display_name": "Python 3", 7 | "language": "python", 8 | "name": "python3" 9 | }, 10 | "language_info": { 11 | "codemirror_mode": { 12 | "name": "ipython", 13 | "version": 3 14 | }, 15 | "file_extension": ".py", 16 | "mimetype": "text/x-python", 17 | "name": "python", 18 | "nbconvert_exporter": "python", 19 | "pygments_lexer": "ipython3", 20 | "version": "3.7.6" 21 | }, 22 | "colab": { 23 | "name": "python_fundamentals_part-1.ipynb", 24 | "provenance": [], 25 | "include_colab_link": true 26 | } 27 | }, 28 | "cells": [ 29 | { 30 | "cell_type": "markdown", 31 | "metadata": { 32 | "id": "view-in-github", 33 | "colab_type": "text" 34 | }, 35 | "source": [ 36 | "\"Open" 37 | ] 38 | }, 39 | { 40 | "cell_type": "markdown", 41 | "metadata": { 42 | "id": "0rYnuumZbVyV", 43 | "colab_type": "text" 44 | }, 45 | "source": [ 46 | "\n", 47 | "# Python Fundamentals - Part-1\n", 48 | "In this notebook, we are going to cover:\n", 49 | "\n", 50 | "* I/O function and indentation\n", 51 | "* Variable and their data types\n", 52 | "* Operations on different data types\n", 53 | "* String formatting and Operators\n", 54 | "* Basic Operators\n", 55 | "* Basics of Python Lists\n" 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "metadata": { 61 | "id": "OJKpzK01ZwcP", 62 | "colab_type": "code", 63 | "colab": {}, 64 | "outputId": "5362e144-d060-44cc-83c8-336d7d1410c2" 65 | }, 66 | "source": [ 67 | "print(\"Hello World!\")" 68 | ], 69 | "execution_count": 0, 70 | "outputs": [ 71 | { 72 | "output_type": "stream", 73 | "text": [ 74 | "Hello World!\n" 75 | ], 76 | "name": "stdout" 77 | } 78 | ] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "metadata": { 83 | "id": "Z4c-w--6ZwcY", 84 | "colab_type": "code", 85 | "colab": {}, 86 | "outputId": "07f2f908-61c5-4250-e4dd-627279ddb2fc" 87 | }, 88 | "source": [ 89 | "input()" 90 | ], 91 | "execution_count": 0, 92 | "outputs": [ 93 | { 94 | "output_type": "stream", 95 | "text": [ 96 | "data science\n" 97 | ], 98 | "name": "stdout" 99 | }, 100 | { 101 | "output_type": "execute_result", 102 | "data": { 103 | "text/plain": [ 104 | "'data science'" 105 | ] 106 | }, 107 | "metadata": { 108 | "tags": [] 109 | }, 110 | "execution_count": 2 111 | } 112 | ] 113 | }, 114 | { 115 | "cell_type": "code", 116 | "metadata": { 117 | "id": "gTcLmNYRZwcc", 118 | "colab_type": "code", 119 | "colab": {}, 120 | "outputId": "dca32a8a-7f85-4e3c-fb3a-4c012a45d9c8" 121 | }, 122 | "source": [ 123 | "a = 5\n", 124 | "if a == 5:\n", 125 | " # 4 indented spaces to this block of code\n", 126 | " print(\"a equals 5\")" 127 | ], 128 | "execution_count": 0, 129 | "outputs": [ 130 | { 131 | "output_type": "stream", 132 | "text": [ 133 | "a equals 5\n" 134 | ], 135 | "name": "stdout" 136 | } 137 | ] 138 | }, 139 | { 140 | "cell_type": "code", 141 | "metadata": { 142 | "id": "abBcWjPUZwcj", 143 | "colab_type": "code", 144 | "colab": {}, 145 | "outputId": "1189d460-f15d-4103-ff0e-57ee67a5004c" 146 | }, 147 | "source": [ 148 | "myString = 'hello world'\n", 149 | "print(type(myString))" 150 | ], 151 | "execution_count": 0, 152 | "outputs": [ 153 | { 154 | "output_type": "stream", 155 | "text": [ 156 | "\n" 157 | ], 158 | "name": "stdout" 159 | } 160 | ] 161 | }, 162 | { 163 | "cell_type": "code", 164 | "metadata": { 165 | "id": "lOrlk-kiZwcp", 166 | "colab_type": "code", 167 | "colab": {}, 168 | "outputId": "d69abe74-0f85-4fd2-84d8-9ab793551ec3" 169 | }, 170 | "source": [ 171 | "n = 10\n", 172 | "print(type(n))" 173 | ], 174 | "execution_count": 0, 175 | "outputs": [ 176 | { 177 | "output_type": "stream", 178 | "text": [ 179 | "\n" 180 | ], 181 | "name": "stdout" 182 | } 183 | ] 184 | }, 185 | { 186 | "cell_type": "code", 187 | "metadata": { 188 | "id": "SGYF1sBHZwcu", 189 | "colab_type": "code", 190 | "colab": {}, 191 | "outputId": "a5fad630-8703-4a62-c0de-54eb46ccecbe" 192 | }, 193 | "source": [ 194 | "n_float = 7.5\n", 195 | "print(type(n_float))" 196 | ], 197 | "execution_count": 0, 198 | "outputs": [ 199 | { 200 | "output_type": "stream", 201 | "text": [ 202 | "\n" 203 | ], 204 | "name": "stdout" 205 | } 206 | ] 207 | }, 208 | { 209 | "cell_type": "code", 210 | "metadata": { 211 | "id": "xZRcpvudZwcz", 212 | "colab_type": "code", 213 | "colab": {}, 214 | "outputId": "4e329fad-a8e6-41bd-f77f-4377496bd813" 215 | }, 216 | "source": [ 217 | "single_string = 'Its a single quote string'\n", 218 | "print(single_string)" 219 | ], 220 | "execution_count": 0, 221 | "outputs": [ 222 | { 223 | "output_type": "error", 224 | "ename": "SyntaxError", 225 | "evalue": "invalid syntax (, line 1)", 226 | "traceback": [ 227 | "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m single_string = 'It's a single quote string'\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" 228 | ] 229 | } 230 | ] 231 | }, 232 | { 233 | "cell_type": "code", 234 | "metadata": { 235 | "id": "w8zH8nMTZwc4", 236 | "colab_type": "code", 237 | "colab": {}, 238 | "outputId": "44dbe354-96a6-4023-ea0f-532c885fd136" 239 | }, 240 | "source": [ 241 | "double_string = \"It's a double quote string\"\n", 242 | "print(double_string)" 243 | ], 244 | "execution_count": 0, 245 | "outputs": [ 246 | { 247 | "output_type": "stream", 248 | "text": [ 249 | "It's a double quote string\n" 250 | ], 251 | "name": "stdout" 252 | } 253 | ] 254 | }, 255 | { 256 | "cell_type": "code", 257 | "metadata": { 258 | "id": "45ACz7IAZwc9", 259 | "colab_type": "code", 260 | "colab": {}, 261 | "outputId": "a90ffd7c-ca11-4063-b11c-7336a40a7eb0" 262 | }, 263 | "source": [ 264 | "n1 = 5\n", 265 | "n2 = 7.5\n", 266 | "print(n1+n2)" 267 | ], 268 | "execution_count": 0, 269 | "outputs": [ 270 | { 271 | "output_type": "stream", 272 | "text": [ 273 | "12.5\n" 274 | ], 275 | "name": "stdout" 276 | } 277 | ] 278 | }, 279 | { 280 | "cell_type": "code", 281 | "metadata": { 282 | "id": "L9uPR7S8ZwdB", 283 | "colab_type": "code", 284 | "colab": {}, 285 | "outputId": "17005e71-bf74-4ed7-db2f-f2ee41d2bc72" 286 | }, 287 | "source": [ 288 | "nstr1 = \"abc\"\n", 289 | "print(nstr1 + n1)" 290 | ], 291 | "execution_count": 0, 292 | "outputs": [ 293 | { 294 | "output_type": "error", 295 | "ename": "TypeError", 296 | "evalue": "can only concatenate str (not \"int\") to str", 297 | "traceback": [ 298 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 299 | "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", 300 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mnstr1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"abc\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnstr1\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mn1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 301 | "\u001b[0;31mTypeError\u001b[0m: can only concatenate str (not \"int\") to str" 302 | ] 303 | } 304 | ] 305 | }, 306 | { 307 | "cell_type": "code", 308 | "metadata": { 309 | "id": "7hL47rL2ZwdF", 310 | "colab_type": "code", 311 | "colab": {}, 312 | "outputId": "556e49b2-efef-49c1-beb5-bd7e15936214" 313 | }, 314 | "source": [ 315 | "nstr2 = \"def\"\n", 316 | "print(nstr1 + nstr2)" 317 | ], 318 | "execution_count": 0, 319 | "outputs": [ 320 | { 321 | "output_type": "stream", 322 | "text": [ 323 | "abcdef\n" 324 | ], 325 | "name": "stdout" 326 | } 327 | ] 328 | }, 329 | { 330 | "cell_type": "code", 331 | "metadata": { 332 | "id": "dHh3wrzEZwdJ", 333 | "colab_type": "code", 334 | "colab": {} 335 | }, 336 | "source": [ 337 | "n1, n2 = 10, 11" 338 | ], 339 | "execution_count": 0, 340 | "outputs": [] 341 | }, 342 | { 343 | "cell_type": "code", 344 | "metadata": { 345 | "id": "k_sPvrAxZwdN", 346 | "colab_type": "code", 347 | "colab": {}, 348 | "outputId": "c1fae2c6-bce4-46c6-abc4-2edb35bb3b9c" 349 | }, 350 | "source": [ 351 | "n1" 352 | ], 353 | "execution_count": 0, 354 | "outputs": [ 355 | { 356 | "output_type": "execute_result", 357 | "data": { 358 | "text/plain": [ 359 | "10" 360 | ] 361 | }, 362 | "metadata": { 363 | "tags": [] 364 | }, 365 | "execution_count": 24 366 | } 367 | ] 368 | }, 369 | { 370 | "cell_type": "code", 371 | "metadata": { 372 | "id": "uM8ntbFHZwdT", 373 | "colab_type": "code", 374 | "colab": {}, 375 | "outputId": "397c8e6f-cc09-4424-a1bb-60c3248d8b17" 376 | }, 377 | "source": [ 378 | "n2" 379 | ], 380 | "execution_count": 0, 381 | "outputs": [ 382 | { 383 | "output_type": "execute_result", 384 | "data": { 385 | "text/plain": [ 386 | "11" 387 | ] 388 | }, 389 | "metadata": { 390 | "tags": [] 391 | }, 392 | "execution_count": 25 393 | } 394 | ] 395 | }, 396 | { 397 | "cell_type": "code", 398 | "metadata": { 399 | "id": "Dbis3Lh_ZwdX", 400 | "colab_type": "code", 401 | "colab": {}, 402 | "outputId": "8abe2bf5-981c-4a6d-bb93-59a8992c8006" 403 | }, 404 | "source": [ 405 | "result = 3 + 4.0 / 2 * 5 # DMAS\n", 406 | "print(result)" 407 | ], 408 | "execution_count": 0, 409 | "outputs": [ 410 | { 411 | "output_type": "stream", 412 | "text": [ 413 | "13.0\n" 414 | ], 415 | "name": "stdout" 416 | } 417 | ] 418 | }, 419 | { 420 | "cell_type": "code", 421 | "metadata": { 422 | "id": "bz3C6xtSZwdd", 423 | "colab_type": "code", 424 | "colab": {}, 425 | "outputId": "6e3c26d5-81b9-4315-ee38-e511681f4b5f" 426 | }, 427 | "source": [ 428 | "# module operator %\n", 429 | "remainder = 17%10\n", 430 | "print(remainder)" 431 | ], 432 | "execution_count": 0, 433 | "outputs": [ 434 | { 435 | "output_type": "stream", 436 | "text": [ 437 | "7\n" 438 | ], 439 | "name": "stdout" 440 | } 441 | ] 442 | }, 443 | { 444 | "cell_type": "code", 445 | "metadata": { 446 | "id": "teGa-QREZwdl", 447 | "colab_type": "code", 448 | "colab": {}, 449 | "outputId": "0201d3b7-1220-48cd-fbb5-19bc420fad62" 450 | }, 451 | "source": [ 452 | "# x ^ n\n", 453 | "x = 5\n", 454 | "n = 4\n", 455 | "print(x ** n)" 456 | ], 457 | "execution_count": 0, 458 | "outputs": [ 459 | { 460 | "output_type": "stream", 461 | "text": [ 462 | "625\n" 463 | ], 464 | "name": "stdout" 465 | } 466 | ] 467 | }, 468 | { 469 | "cell_type": "code", 470 | "metadata": { 471 | "id": "Ip07RFsZZwdp", 472 | "colab_type": "code", 473 | "colab": {} 474 | }, 475 | "source": [ 476 | "nstr = \"abc\"\n", 477 | "ans = nstr * 10" 478 | ], 479 | "execution_count": 0, 480 | "outputs": [] 481 | }, 482 | { 483 | "cell_type": "code", 484 | "metadata": { 485 | "id": "YbFxbZYIZwds", 486 | "colab_type": "code", 487 | "colab": {}, 488 | "outputId": "856bcdc1-42cd-4ebf-ae3a-0e66e4b40dd5" 489 | }, 490 | "source": [ 491 | "print(len(ans))" 492 | ], 493 | "execution_count": 0, 494 | "outputs": [ 495 | { 496 | "output_type": "stream", 497 | "text": [ 498 | "30\n" 499 | ], 500 | "name": "stdout" 501 | } 502 | ] 503 | }, 504 | { 505 | "cell_type": "code", 506 | "metadata": { 507 | "id": "CpgmSk--Zwdx", 508 | "colab_type": "code", 509 | "colab": {}, 510 | "outputId": "b4aa473d-aa95-404d-e5a5-1bb5fc83f3e9" 511 | }, 512 | "source": [ 513 | "name = \"Harshit\"\n", 514 | "print(\"%s is a data scientist!\" %name)" 515 | ], 516 | "execution_count": 0, 517 | "outputs": [ 518 | { 519 | "output_type": "stream", 520 | "text": [ 521 | "Harshit is a data scientist!\n" 522 | ], 523 | "name": "stdout" 524 | } 525 | ] 526 | }, 527 | { 528 | "cell_type": "code", 529 | "metadata": { 530 | "id": "atXjzC-5Zwd1", 531 | "colab_type": "code", 532 | "colab": {}, 533 | "outputId": "bf8f2d58-b5ce-4c99-df16-60670db6e909" 534 | }, 535 | "source": [ 536 | "name.upper()" 537 | ], 538 | "execution_count": 0, 539 | "outputs": [ 540 | { 541 | "output_type": "execute_result", 542 | "data": { 543 | "text/plain": [ 544 | "'HARSHIT'" 545 | ] 546 | }, 547 | "metadata": { 548 | "tags": [] 549 | }, 550 | "execution_count": 40 551 | } 552 | ] 553 | }, 554 | { 555 | "cell_type": "code", 556 | "metadata": { 557 | "id": "BROnctgPZwd5", 558 | "colab_type": "code", 559 | "colab": {}, 560 | "outputId": "710fd5f1-a4a2-4423-a847-aeb3bfd3c05a" 561 | }, 562 | "source": [ 563 | "name.lower()" 564 | ], 565 | "execution_count": 0, 566 | "outputs": [ 567 | { 568 | "output_type": "execute_result", 569 | "data": { 570 | "text/plain": [ 571 | "'harshit'" 572 | ] 573 | }, 574 | "metadata": { 575 | "tags": [] 576 | }, 577 | "execution_count": 41 578 | } 579 | ] 580 | }, 581 | { 582 | "cell_type": "code", 583 | "metadata": { 584 | "id": "QWvzhR41Zwd_", 585 | "colab_type": "code", 586 | "colab": {}, 587 | "outputId": "4920717f-0398-4e9e-995e-1f8227d60630" 588 | }, 589 | "source": [ 590 | "nstr = \"it is a nice day today.\"\n", 591 | "nstr.capitalize()" 592 | ], 593 | "execution_count": 0, 594 | "outputs": [ 595 | { 596 | "output_type": "execute_result", 597 | "data": { 598 | "text/plain": [ 599 | "'It is a nice day today.'" 600 | ] 601 | }, 602 | "metadata": { 603 | "tags": [] 604 | }, 605 | "execution_count": 42 606 | } 607 | ] 608 | }, 609 | { 610 | "cell_type": "code", 611 | "metadata": { 612 | "id": "R2ROF-N8ZweD", 613 | "colab_type": "code", 614 | "colab": {}, 615 | "outputId": "3e9a3a14-e469-46e1-ff07-5f54b3844e27" 616 | }, 617 | "source": [ 618 | "name.index('s')" 619 | ], 620 | "execution_count": 0, 621 | "outputs": [ 622 | { 623 | "output_type": "execute_result", 624 | "data": { 625 | "text/plain": [ 626 | "3" 627 | ] 628 | }, 629 | "metadata": { 630 | "tags": [] 631 | }, 632 | "execution_count": 44 633 | } 634 | ] 635 | }, 636 | { 637 | "cell_type": "code", 638 | "metadata": { 639 | "id": "vjKGED4eZweH", 640 | "colab_type": "code", 641 | "colab": {}, 642 | "outputId": "fef0c3e1-cb10-48d6-e43c-c909156360fa" 643 | }, 644 | "source": [ 645 | "name[2:5]" 646 | ], 647 | "execution_count": 0, 648 | "outputs": [ 649 | { 650 | "output_type": "execute_result", 651 | "data": { 652 | "text/plain": [ 653 | "'rsh'" 654 | ] 655 | }, 656 | "metadata": { 657 | "tags": [] 658 | }, 659 | "execution_count": 45 660 | } 661 | ] 662 | }, 663 | { 664 | "cell_type": "code", 665 | "metadata": { 666 | "id": "8PBwGtuhZweK", 667 | "colab_type": "code", 668 | "colab": {}, 669 | "outputId": "fce320d4-6aca-4059-ac69-d2fb9bf32b4b" 670 | }, 671 | "source": [ 672 | "name[2:6:2]" 673 | ], 674 | "execution_count": 0, 675 | "outputs": [ 676 | { 677 | "output_type": "execute_result", 678 | "data": { 679 | "text/plain": [ 680 | "'rh'" 681 | ] 682 | }, 683 | "metadata": { 684 | "tags": [] 685 | }, 686 | "execution_count": 46 687 | } 688 | ] 689 | }, 690 | { 691 | "cell_type": "code", 692 | "metadata": { 693 | "id": "AKgDmpq3ZweP", 694 | "colab_type": "code", 695 | "colab": {}, 696 | "outputId": "05a5781e-81fb-418e-f784-2f52f77290d3" 697 | }, 698 | "source": [ 699 | "alist = [3,4,5]\n", 700 | "print(alist)" 701 | ], 702 | "execution_count": 0, 703 | "outputs": [ 704 | { 705 | "output_type": "stream", 706 | "text": [ 707 | "[3, 4, 5]\n" 708 | ], 709 | "name": "stdout" 710 | } 711 | ] 712 | }, 713 | { 714 | "cell_type": "code", 715 | "metadata": { 716 | "id": "YKqSZxXMZweR", 717 | "colab_type": "code", 718 | "colab": {}, 719 | "outputId": "251b3422-8bf8-4b21-a82c-ab786e4e8c46" 720 | }, 721 | "source": [ 722 | "alist = ['harshit', 2, 5.5]\n", 723 | "print(alist)" 724 | ], 725 | "execution_count": 0, 726 | "outputs": [ 727 | { 728 | "output_type": "stream", 729 | "text": [ 730 | "['harshit', 2, 5.5]\n" 731 | ], 732 | "name": "stdout" 733 | } 734 | ] 735 | }, 736 | { 737 | "cell_type": "code", 738 | "metadata": { 739 | "id": "j_qJCbh6ZweU", 740 | "colab_type": "code", 741 | "colab": {}, 742 | "outputId": "405e39dd-4256-4fe5-d25e-10f64d739c64" 743 | }, 744 | "source": [ 745 | "alist.append(10)\n", 746 | "alist.append(15)\n", 747 | "print(alist)" 748 | ], 749 | "execution_count": 0, 750 | "outputs": [ 751 | { 752 | "output_type": "stream", 753 | "text": [ 754 | "['harshit', 2, 5.5, 10, 15]\n" 755 | ], 756 | "name": "stdout" 757 | } 758 | ] 759 | }, 760 | { 761 | "cell_type": "code", 762 | "metadata": { 763 | "id": "lQRu9ys2ZweX", 764 | "colab_type": "code", 765 | "colab": {}, 766 | "outputId": "0d7cdee6-6704-4ce6-f338-8a6d4f456276" 767 | }, 768 | "source": [ 769 | "alist.pop()\n", 770 | "print(alist)" 771 | ], 772 | "execution_count": 0, 773 | "outputs": [ 774 | { 775 | "output_type": "stream", 776 | "text": [ 777 | "['harshit', 2, 5.5, 10]\n" 778 | ], 779 | "name": "stdout" 780 | } 781 | ] 782 | }, 783 | { 784 | "cell_type": "code", 785 | "metadata": { 786 | "id": "wTe8rfuhZwed", 787 | "colab_type": "code", 788 | "colab": {}, 789 | "outputId": "98a5802c-1367-4da3-f138-9c9640a0b8e2" 790 | }, 791 | "source": [ 792 | "alist[3]" 793 | ], 794 | "execution_count": 0, 795 | "outputs": [ 796 | { 797 | "output_type": "execute_result", 798 | "data": { 799 | "text/plain": [ 800 | "10" 801 | ] 802 | }, 803 | "metadata": { 804 | "tags": [] 805 | }, 806 | "execution_count": 53 807 | } 808 | ] 809 | }, 810 | { 811 | "cell_type": "code", 812 | "metadata": { 813 | "id": "uHVn8hV8Zwei", 814 | "colab_type": "code", 815 | "colab": {}, 816 | "outputId": "08442004-c3b5-4a0b-80cc-b2ea2970390b" 817 | }, 818 | "source": [ 819 | "alist[1:]" 820 | ], 821 | "execution_count": 0, 822 | "outputs": [ 823 | { 824 | "output_type": "execute_result", 825 | "data": { 826 | "text/plain": [ 827 | "[2, 5.5, 10]" 828 | ] 829 | }, 830 | "metadata": { 831 | "tags": [] 832 | }, 833 | "execution_count": 54 834 | } 835 | ] 836 | }, 837 | { 838 | "cell_type": "code", 839 | "metadata": { 840 | "id": "AUlw133RZwem", 841 | "colab_type": "code", 842 | "colab": {}, 843 | "outputId": "4afc1b30-e1f9-4551-b491-8c0a9dbf134c" 844 | }, 845 | "source": [ 846 | "alist.append([1,2,3])\n", 847 | "print(alist)" 848 | ], 849 | "execution_count": 0, 850 | "outputs": [ 851 | { 852 | "output_type": "stream", 853 | "text": [ 854 | "['harshit', 2, 5.5, 10, [1, 2, 3]]\n" 855 | ], 856 | "name": "stdout" 857 | } 858 | ] 859 | }, 860 | { 861 | "cell_type": "code", 862 | "metadata": { 863 | "id": "ZZII_cfFZwer", 864 | "colab_type": "code", 865 | "colab": {}, 866 | "outputId": "267f9bde-29bc-43b0-982b-e3248581050d" 867 | }, 868 | "source": [ 869 | "alist*2" 870 | ], 871 | "execution_count": 0, 872 | "outputs": [ 873 | { 874 | "output_type": "execute_result", 875 | "data": { 876 | "text/plain": [ 877 | "['harshit', 2, 5.5, 10, [1, 2, 3], 'harshit', 2, 5.5, 10, [1, 2, 3]]" 878 | ] 879 | }, 880 | "metadata": { 881 | "tags": [] 882 | }, 883 | "execution_count": 56 884 | } 885 | ] 886 | }, 887 | { 888 | "cell_type": "code", 889 | "metadata": { 890 | "id": "WzKLOsbjZweu", 891 | "colab_type": "code", 892 | "colab": {}, 893 | "outputId": "da11b84b-7265-4736-a161-240bca14aba0" 894 | }, 895 | "source": [ 896 | "alist + alist" 897 | ], 898 | "execution_count": 0, 899 | "outputs": [ 900 | { 901 | "output_type": "execute_result", 902 | "data": { 903 | "text/plain": [ 904 | "['harshit', 2, 5.5, 10, [1, 2, 3], 'harshit', 2, 5.5, 10, [1, 2, 3]]" 905 | ] 906 | }, 907 | "metadata": { 908 | "tags": [] 909 | }, 910 | "execution_count": 57 911 | } 912 | ] 913 | } 914 | ] 915 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # python_fundamentals 2 | Python fundamentals is a series of tutorials on Basic Python knowledge required to get started in the field of Data Science. 3 | -------------------------------------------------------------------------------- /images/Group 86 (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dswh/python_fundamentals/df1aac0f9e9fc0655f9189982987b79abd0340b2/images/Group 86 (1).png --------------------------------------------------------------------------------