├── 10_Python_101_Data_Visualization_with_Seaborn.ipynb ├── 1_Python_101_Variables_Assignment,_Math_Ops,_Precedence,_and_Print_Get_.ipynb ├── 2_Python_101_Data_Types.ipynb ├── 3_Python_101_Comparison,_Logical_Operators,_Conditional_Statements_.ipynb ├── 4_Python_101_For_While_Loops,_Range,_List_Comprehension_.ipynb ├── 5_Python_101_Functions_.ipynb ├── 6_Python_101_Files.ipynb ├── 7_Python_101_Python_Libraries_for_Data_Analysis_Numpy.ipynb ├── 8_Python_101_Python_Libraries_for_Data_Analysis_Pandas.ipynb ├── 9_Python_101_Data_Visualization_with_matplotlib.ipynb ├── Finance_101_1_Stocks_Data_Analysis_and_Visualization.ipynb ├── Finance_101_2_Portfolio_Assets_Allocation_and_Statistical_Data_Analysis.ipynb ├── README.md ├── S_P500_Stock_Data.csv ├── bank_client_information.csv ├── daily_returns.csv ├── fruits_input.txt ├── sample_csv_file.csv ├── sample_text_file.txt ├── stock.csv └── stocks.csv /3_Python_101_Comparison,_Logical_Operators,_Conditional_Statements_.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "3. Python 101 - Comparison, Logical Operators, Conditional Statements .ipynb", 7 | "provenance": [], 8 | "collapsed_sections": [], 9 | "include_colab_link": true 10 | }, 11 | "kernelspec": { 12 | "name": "python3", 13 | "display_name": "Python 3" 14 | } 15 | }, 16 | "cells": [ 17 | { 18 | "cell_type": "markdown", 19 | "metadata": { 20 | "id": "view-in-github", 21 | "colab_type": "text" 22 | }, 23 | "source": [ 24 | "\"Open" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": { 30 | "id": "CV9YCHsGtAP5" 31 | }, 32 | "source": [ 33 | "# 1. COMPARISON OPERATORS\n" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "metadata": { 39 | "id": "o9VtOcrKtCc1", 40 | "outputId": "4df88eb3-efe6-4392-c7f9-491683a90d91", 41 | "colab": { 42 | "base_uri": "https://localhost:8080/" 43 | } 44 | }, 45 | "source": [ 46 | "# Comparison Operator output could be \"True\" or \"False\"\n", 47 | "# Let's cover equal '==' comparison operator first\n", 48 | "# It's simply a question: \"Is stock_1_price equals stock_2_price or not?\"\n", 49 | "# \"True\" output means condition is satisfied \n", 50 | "# \"False\" output means Condition is not satisfied (condition is not true) \n", 51 | "\n", 52 | "stock_1_price = 1000\n", 53 | "stock_2_price = 1000\n", 54 | "\n", 55 | "stock_1_price == stock_2_price\n" 56 | ], 57 | "execution_count": 2, 58 | "outputs": [ 59 | { 60 | "output_type": "execute_result", 61 | "data": { 62 | "text/plain": [ 63 | "True" 64 | ] 65 | }, 66 | "metadata": { 67 | "tags": [] 68 | }, 69 | "execution_count": 2 70 | } 71 | ] 72 | }, 73 | { 74 | "cell_type": "code", 75 | "metadata": { 76 | "id": "l48NWuCztX5G", 77 | "outputId": "203e1e8d-7df1-42af-e32f-87020bae5d18", 78 | "colab": { 79 | "base_uri": "https://localhost:8080/" 80 | } 81 | }, 82 | "source": [ 83 | "# Greater than or equal operator '>='\n", 84 | "\n", 85 | "stock_1_price >= stock_2_price" 86 | ], 87 | "execution_count": 3, 88 | "outputs": [ 89 | { 90 | "output_type": "execute_result", 91 | "data": { 92 | "text/plain": [ 93 | "True" 94 | ] 95 | }, 96 | "metadata": { 97 | "tags": [] 98 | }, 99 | "execution_count": 3 100 | } 101 | ] 102 | }, 103 | { 104 | "cell_type": "code", 105 | "metadata": { 106 | "id": "RmUrcn31tY0_" 107 | }, 108 | "source": [ 109 | "# Note that '==' is a comparison operator \n", 110 | "# Note that '=' is used for variable assignment (put 10 in stock_1_price)\n", 111 | "\n", 112 | "stock_1_price = 10" 113 | ], 114 | "execution_count": 4, 115 | "outputs": [] 116 | }, 117 | { 118 | "cell_type": "code", 119 | "metadata": { 120 | "id": "TttdgxEPtY3z", 121 | "outputId": "9c33ac73-4cb2-4503-fd4f-276bfd08f844", 122 | "colab": { 123 | "base_uri": "https://localhost:8080/" 124 | } 125 | }, 126 | "source": [ 127 | "stock_1_price" 128 | ], 129 | "execution_count": 5, 130 | "outputs": [ 131 | { 132 | "output_type": "execute_result", 133 | "data": { 134 | "text/plain": [ 135 | "10" 136 | ] 137 | }, 138 | "metadata": { 139 | "tags": [] 140 | }, 141 | "execution_count": 5 142 | } 143 | ] 144 | }, 145 | { 146 | "cell_type": "code", 147 | "metadata": { 148 | "id": "9fvPnQePtY9K", 149 | "outputId": "2364d974-c36c-47c1-eed3-6016bfee3aee", 150 | "colab": { 151 | "base_uri": "https://localhost:8080/" 152 | } 153 | }, 154 | "source": [ 155 | "# Comparison operators work with strings as well\n", 156 | "\n", 157 | "'hello' == 'Hello'" 158 | ], 159 | "execution_count": 6, 160 | "outputs": [ 161 | { 162 | "output_type": "execute_result", 163 | "data": { 164 | "text/plain": [ 165 | "False" 166 | ] 167 | }, 168 | "metadata": { 169 | "tags": [] 170 | }, 171 | "execution_count": 6 172 | } 173 | ] 174 | }, 175 | { 176 | "cell_type": "code", 177 | "metadata": { 178 | "id": "krIE9oTdtj-Q", 179 | "outputId": "c9db9e4b-902f-45d4-a8c9-e0d05c2e8bcb", 180 | "colab": { 181 | "base_uri": "https://localhost:8080/", 182 | "height": 34 183 | } 184 | }, 185 | "source": [ 186 | "# Both strings have to exactly match (lower case vs. upper case)\n" 187 | ], 188 | "execution_count": null, 189 | "outputs": [ 190 | { 191 | "output_type": "execute_result", 192 | "data": { 193 | "text/plain": [ 194 | "False" 195 | ] 196 | }, 197 | "metadata": { 198 | "tags": [] 199 | }, 200 | "execution_count": 11 201 | } 202 | ] 203 | }, 204 | { 205 | "cell_type": "code", 206 | "metadata": { 207 | "id": "WI6k596Xtlcc", 208 | "outputId": "03e254fd-cfb6-4e2e-d510-a856fc46c3df", 209 | "colab": { 210 | "base_uri": "https://localhost:8080/" 211 | } 212 | }, 213 | "source": [ 214 | "# Not equal comparison operator '!='\n", 215 | "\n", 216 | "'hello' != 'Hello'" 217 | ], 218 | "execution_count": 7, 219 | "outputs": [ 220 | { 221 | "output_type": "execute_result", 222 | "data": { 223 | "text/plain": [ 224 | "True" 225 | ] 226 | }, 227 | "metadata": { 228 | "tags": [] 229 | }, 230 | "execution_count": 7 231 | } 232 | ] 233 | }, 234 | { 235 | "cell_type": "markdown", 236 | "metadata": { 237 | "id": "eNyKRJob4Xlo" 238 | }, 239 | "source": [ 240 | "**MINI CHALLENGE #1:**\n", 241 | "- **Without executing the code cell, What will this code generate?**\n", 242 | "\n", 243 | "```\n", 244 | "stock_1_price = 15\n", 245 | "stock_2_price = 10\n", 246 | "\n", 247 | "print(stock_1_price == stock_2_price) \n", 248 | "print(stock_1_price != stock_2_price) \n", 249 | "print(stock_1_price > stock_2_price)\n", 250 | "print(stock_1_price < stock_2_price) \n", 251 | "```\n" 252 | ] 253 | }, 254 | { 255 | "cell_type": "code", 256 | "metadata": { 257 | "id": "-vRyMcIhlVPg", 258 | "outputId": "3b92391b-aff0-4b25-dbbf-cad880f0341f", 259 | "colab": { 260 | "base_uri": "https://localhost:8080/" 261 | } 262 | }, 263 | "source": [ 264 | "stock_1_price = 15\n", 265 | "stock_2_price = 10\n", 266 | " \n", 267 | "print(stock_1_price == stock_2_price) \n", 268 | "print(stock_1_price != stock_2_price) \n", 269 | "print(stock_1_price > stock_2_price)\n", 270 | "print(stock_1_price < stock_2_price) " 271 | ], 272 | "execution_count": 8, 273 | "outputs": [ 274 | { 275 | "output_type": "stream", 276 | "text": [ 277 | "False\n", 278 | "True\n", 279 | "True\n", 280 | "False\n" 281 | ], 282 | "name": "stdout" 283 | } 284 | ] 285 | }, 286 | { 287 | "cell_type": "markdown", 288 | "metadata": { 289 | "id": "4ElLliXmvffI" 290 | }, 291 | "source": [ 292 | "# 2. LOGICAL OPERATORS" 293 | ] 294 | }, 295 | { 296 | "cell_type": "code", 297 | "metadata": { 298 | "id": "DZ4lIrr9viXb", 299 | "outputId": "1cd6238d-9494-47f3-ca88-0360cd84e74c", 300 | "colab": { 301 | "base_uri": "https://localhost:8080/" 302 | } 303 | }, 304 | "source": [ 305 | "# For \"and\" logical operators, both arguments must be \"True\" in order for the output to be \"True\" \n", 306 | "# (Note that this is the only case in which the 'and' logical operator generates a True output)\n", 307 | "# 1 and 1 = 1\n", 308 | "\n", 309 | "1 and 1 == 1" 310 | ], 311 | "execution_count": 10, 312 | "outputs": [ 313 | { 314 | "output_type": "execute_result", 315 | "data": { 316 | "text/plain": [ 317 | "True" 318 | ] 319 | }, 320 | "metadata": { 321 | "tags": [] 322 | }, 323 | "execution_count": 10 324 | } 325 | ] 326 | }, 327 | { 328 | "cell_type": "code", 329 | "metadata": { 330 | "id": "tBllQqO2vxPe", 331 | "outputId": "c171dd62-ec2e-47ce-cd6a-4c3838a0d4d7", 332 | "colab": { 333 | "base_uri": "https://localhost:8080/" 334 | } 335 | }, 336 | "source": [ 337 | " 0 and 1 == 0\n" 338 | ], 339 | "execution_count": 13, 340 | "outputs": [ 341 | { 342 | "output_type": "execute_result", 343 | "data": { 344 | "text/plain": [ 345 | "0" 346 | ] 347 | }, 348 | "metadata": { 349 | "tags": [] 350 | }, 351 | "execution_count": 13 352 | } 353 | ] 354 | }, 355 | { 356 | "cell_type": "code", 357 | "metadata": { 358 | "id": "ebgLEPrQvy1h", 359 | "outputId": "b56331e0-dae7-4084-e25e-3c9ef61888a2", 360 | "colab": { 361 | "base_uri": "https://localhost:8080/" 362 | } 363 | }, 364 | "source": [ 365 | " 0 and 0 == 0\n" 366 | ], 367 | "execution_count": 14, 368 | "outputs": [ 369 | { 370 | "output_type": "execute_result", 371 | "data": { 372 | "text/plain": [ 373 | "0" 374 | ] 375 | }, 376 | "metadata": { 377 | "tags": [] 378 | }, 379 | "execution_count": 14 380 | } 381 | ] 382 | }, 383 | { 384 | "cell_type": "code", 385 | "metadata": { 386 | "id": "Y_FB6C6yvzqb", 387 | "outputId": "74a28864-988f-4045-9433-c446e455a6a6", 388 | "colab": { 389 | "base_uri": "https://localhost:8080/" 390 | } 391 | }, 392 | "source": [ 393 | "# For \"or\" logical operators, if any one of the arguments is \"True\", the output will be \"True\" \n", 394 | "\n", 395 | " \n", 396 | "1 or 1 == 1" 397 | ], 398 | "execution_count": 19, 399 | "outputs": [ 400 | { 401 | "output_type": "execute_result", 402 | "data": { 403 | "text/plain": [ 404 | "1" 405 | ] 406 | }, 407 | "metadata": { 408 | "tags": [] 409 | }, 410 | "execution_count": 19 411 | } 412 | ] 413 | }, 414 | { 415 | "cell_type": "code", 416 | "metadata": { 417 | "id": "kiy1MhGrvzu9", 418 | "outputId": "519189af-44ed-415a-f794-72f7713f0428", 419 | "colab": { 420 | "base_uri": "https://localhost:8080/" 421 | } 422 | }, 423 | "source": [ 424 | "1 or 0 == 1\n" 425 | ], 426 | "execution_count": 28, 427 | "outputs": [ 428 | { 429 | "output_type": "execute_result", 430 | "data": { 431 | "text/plain": [ 432 | "1" 433 | ] 434 | }, 435 | "metadata": { 436 | "tags": [] 437 | }, 438 | "execution_count": 28 439 | } 440 | ] 441 | }, 442 | { 443 | "cell_type": "code", 444 | "metadata": { 445 | "id": "S9Zo0wWovz2j", 446 | "outputId": "25fc0a7f-f638-438b-a416-5b0b9caf3f64", 447 | "colab": { 448 | "base_uri": "https://localhost:8080/" 449 | } 450 | }, 451 | "source": [ 452 | "0 or 1 == 1\n" 453 | ], 454 | "execution_count": 22, 455 | "outputs": [ 456 | { 457 | "output_type": "execute_result", 458 | "data": { 459 | "text/plain": [ 460 | "True" 461 | ] 462 | }, 463 | "metadata": { 464 | "tags": [] 465 | }, 466 | "execution_count": 22 467 | } 468 | ] 469 | }, 470 | { 471 | "cell_type": "code", 472 | "metadata": { 473 | "id": "Tu1BB3FAvz8-", 474 | "outputId": "8f73432d-b0ef-465c-a5da-abf5779d3425", 475 | "colab": { 476 | "base_uri": "https://localhost:8080/" 477 | } 478 | }, 479 | "source": [ 480 | "# 0 or 0 = 0 (Note that this is the only case in which the 'or' logical operator generates a False output)\n", 481 | "\n", 482 | "False or False" 483 | ], 484 | "execution_count": 29, 485 | "outputs": [ 486 | { 487 | "output_type": "execute_result", 488 | "data": { 489 | "text/plain": [ 490 | "False" 491 | ] 492 | }, 493 | "metadata": { 494 | "tags": [] 495 | }, 496 | "execution_count": 29 497 | } 498 | ] 499 | }, 500 | { 501 | "cell_type": "code", 502 | "metadata": { 503 | "id": "KC9ArCvsvz7J", 504 | "outputId": "9c032a3b-18fc-4c08-90e3-7419bd4a543f", 505 | "colab": { 506 | "base_uri": "https://localhost:8080/" 507 | } 508 | }, 509 | "source": [ 510 | " True and False == False \n" 511 | ], 512 | "execution_count": 26, 513 | "outputs": [ 514 | { 515 | "output_type": "execute_result", 516 | "data": { 517 | "text/plain": [ 518 | "True" 519 | ] 520 | }, 521 | "metadata": { 522 | "tags": [] 523 | }, 524 | "execution_count": 26 525 | } 526 | ] 527 | }, 528 | { 529 | "cell_type": "code", 530 | "metadata": { 531 | "id": "1kVyRF3Avz5V", 532 | "outputId": "e19373a3-eb1a-43f3-ead9-d3240e348823", 533 | "colab": { 534 | "base_uri": "https://localhost:8080/" 535 | } 536 | }, 537 | "source": [ 538 | " True or False == True\n" 539 | ], 540 | "execution_count": 30, 541 | "outputs": [ 542 | { 543 | "output_type": "execute_result", 544 | "data": { 545 | "text/plain": [ 546 | "True" 547 | ] 548 | }, 549 | "metadata": { 550 | "tags": [] 551 | }, 552 | "execution_count": 30 553 | } 554 | ] 555 | }, 556 | { 557 | "cell_type": "markdown", 558 | "metadata": { 559 | "id": "vjvXsd7ezN4y" 560 | }, 561 | "source": [ 562 | "**MINI CHALLENGE #2:**\n", 563 | "- **Without executing the code cell, What will these two lines of code generate?**\n", 564 | "\n", 565 | "```\n", 566 | "print('FINANCE'!='FINANCE' and (10 > 3) and (20 == 20)) \n", 567 | "```\n", 568 | "\n", 569 | "```\n", 570 | "print('Finance'!='FINANCE' or (16 > 20) or (25 == 25)) \n", 571 | "```\n" 572 | ] 573 | }, 574 | { 575 | "cell_type": "code", 576 | "metadata": { 577 | "id": "4u7cWLq15VZt", 578 | "outputId": "e00f255a-8f0d-4175-98e0-990667e088c7", 579 | "colab": { 580 | "base_uri": "https://localhost:8080/" 581 | } 582 | }, 583 | "source": [ 584 | "print('FINANCE'!='FINANCE' and (10 > 3) and (20 == 20)) \n", 585 | "print('Finance'!='FINANCE' or (16 > 20) or (25 == 25)) " 586 | ], 587 | "execution_count": 32, 588 | "outputs": [ 589 | { 590 | "output_type": "stream", 591 | "text": [ 592 | "False\n", 593 | "True\n" 594 | ], 595 | "name": "stdout" 596 | } 597 | ] 598 | }, 599 | { 600 | "cell_type": "markdown", 601 | "metadata": { 602 | "id": "GVMXs0iZ0xJp" 603 | }, 604 | "source": [ 605 | "**MINI CHALLENGE #3:**\n", 606 | "- **Without executing the code cell, What will these two lines of code generate?**\n", 607 | "\n", 608 | "```\n", 609 | "a = 5\n", 610 | "b = 3.5\n", 611 | "\n", 612 | "print(a == b or a != b) \n", 613 | "print(a == b and a != b) \n", 614 | "```\n", 615 | "\n" 616 | ] 617 | }, 618 | { 619 | "cell_type": "code", 620 | "metadata": { 621 | "id": "xA9pXas-5WJB", 622 | "outputId": "590dcf6b-fc2d-41c2-f642-0ab9c2b1d35d", 623 | "colab": { 624 | "base_uri": "https://localhost:8080/" 625 | } 626 | }, 627 | "source": [ 628 | "a = 5\n", 629 | "b = 3.5\n", 630 | " \n", 631 | "print(a == b or a != b) \n", 632 | "print(a == b and a != b) " 633 | ], 634 | "execution_count": 33, 635 | "outputs": [ 636 | { 637 | "output_type": "stream", 638 | "text": [ 639 | "True\n", 640 | "False\n" 641 | ], 642 | "name": "stdout" 643 | } 644 | ] 645 | }, 646 | { 647 | "cell_type": "markdown", 648 | "metadata": { 649 | "id": "STR2UADaxtHC" 650 | }, 651 | "source": [ 652 | "# 3. CONDITIONAL STATEMENTS" 653 | ] 654 | }, 655 | { 656 | "cell_type": "markdown", 657 | "metadata": { 658 | "id": "owrJExRxX--G" 659 | }, 660 | "source": [ 661 | "- A simple if-else statement is written in Python as follows:\n", 662 | "\n", 663 | "```\n", 664 | "if condition:\n", 665 | " statement #1\n", 666 | "else:\n", 667 | " statement #2\n", 668 | "```\n", 669 | "\n", 670 | "- If the condition is true, execute the first indented statement\n", 671 | "- if the condition is not true, then execute the else indented statements. \n", 672 | "- Note that Python uses indentation (whitespace) to indicate code sections and scope." 673 | ] 674 | }, 675 | { 676 | "cell_type": "code", 677 | "metadata": { 678 | "id": "9iiHeyl_xvte", 679 | "outputId": "8d604b1b-5f8b-4a01-ef40-5fb0ae935d33", 680 | "colab": { 681 | "base_uri": "https://localhost:8080/" 682 | } 683 | }, 684 | "source": [ 685 | "if 10 > 9 :\n", 686 | " print('If condition is True')\n", 687 | "else:\n", 688 | " print(\"If condition is False\")" 689 | ], 690 | "execution_count": 35, 691 | "outputs": [ 692 | { 693 | "output_type": "stream", 694 | "text": [ 695 | "If condition is True\n" 696 | ], 697 | "name": "stdout" 698 | } 699 | ] 700 | }, 701 | { 702 | "cell_type": "code", 703 | "metadata": { 704 | "id": "M05mmLIWxzCP", 705 | "outputId": "ffeae5e5-8533-4da8-d2f1-e65f6e2ca35f", 706 | "colab": { 707 | "base_uri": "https://localhost:8080/" 708 | } 709 | }, 710 | "source": [ 711 | "if 10 > 19 :\n", 712 | " print('If condition is True')\n", 713 | "else:\n", 714 | " print(\"If condition is False\")" 715 | ], 716 | "execution_count": 36, 717 | "outputs": [ 718 | { 719 | "output_type": "stream", 720 | "text": [ 721 | "If condition is False\n" 722 | ], 723 | "name": "stdout" 724 | } 725 | ] 726 | }, 727 | { 728 | "cell_type": "code", 729 | "metadata": { 730 | "id": "4i8g3ORFxzFn", 731 | "outputId": "8f41e0c7-024b-4aa3-c07e-00f403888803", 732 | "colab": { 733 | "base_uri": "https://localhost:8080/" 734 | } 735 | }, 736 | "source": [ 737 | "if 5 == 10:\n", 738 | " print('If condition is True')\n", 739 | "else:\n", 740 | " print(\"If condition is False\")" 741 | ], 742 | "execution_count": 37, 743 | "outputs": [ 744 | { 745 | "output_type": "stream", 746 | "text": [ 747 | "If condition is False\n" 748 | ], 749 | "name": "stdout" 750 | } 751 | ] 752 | }, 753 | { 754 | "cell_type": "code", 755 | "metadata": { 756 | "id": "cZKbXTtVxzAG", 757 | "outputId": "96dee135-8179-457a-fee7-e81b9f455fda", 758 | "colab": { 759 | "base_uri": "https://localhost:8080/" 760 | } 761 | }, 762 | "source": [ 763 | "if 10 > 19 :\n", 764 | " print('If condition1 is True')\n", 765 | "elif 20 ==21:\n", 766 | " print(\"If condition2 is True\")\n", 767 | "else:\n", 768 | " print(\"Last statement is True\")" 769 | ], 770 | "execution_count": 39, 771 | "outputs": [ 772 | { 773 | "output_type": "stream", 774 | "text": [ 775 | "Last statement is True\n" 776 | ], 777 | "name": "stdout" 778 | } 779 | ] 780 | }, 781 | { 782 | "cell_type": "code", 783 | "metadata": { 784 | "id": "qXCMo76Wxy95", 785 | "outputId": "fc1a176c-f7e0-41eb-a390-265739e84dd6", 786 | "colab": { 787 | "base_uri": "https://localhost:8080/" 788 | } 789 | }, 790 | "source": [ 791 | "# Let's take an input from the user and grant or deny access accordingly\n", 792 | "\n", 793 | "user_name = str(input('Enter your username: '))\n", 794 | "if user_name == 'Ryan':\n", 795 | " print('Access granted')\n", 796 | "else:\n", 797 | " print(\"Access denied.\")" 798 | ], 799 | "execution_count": 41, 800 | "outputs": [ 801 | { 802 | "output_type": "stream", 803 | "text": [ 804 | "Enter your username: Ryan\n", 805 | "Access granted\n" 806 | ], 807 | "name": "stdout" 808 | } 809 | ] 810 | }, 811 | { 812 | "cell_type": "code", 813 | "metadata": { 814 | "id": "mgZaUUxhxy75", 815 | "outputId": "8e624e3f-a19f-4705-99a4-0571545f045c", 816 | "colab": { 817 | "base_uri": "https://localhost:8080/" 818 | } 819 | }, 820 | "source": [ 821 | "# Let's make the code more robust (case insensitive)\n", 822 | "\n", 823 | "user_name = str(input('Enter your username: '))\n", 824 | "if user_name.lower() == 'Ryan'.lower():\n", 825 | " print('Access granted')\n", 826 | "else:\n", 827 | " print(\"Access denied.\")\n" 828 | ], 829 | "execution_count": 43, 830 | "outputs": [ 831 | { 832 | "output_type": "stream", 833 | "text": [ 834 | "Enter your username: ryan\n", 835 | "Access granted\n" 836 | ], 837 | "name": "stdout" 838 | } 839 | ] 840 | }, 841 | { 842 | "cell_type": "markdown", 843 | "metadata": { 844 | "id": "E9b_qCZ12Baz" 845 | }, 846 | "source": [ 847 | "**MINI CHALLENGE #4:**\n", 848 | "- **Write a code that takes a number from the user and indicates if it's positive or negative**" 849 | ] 850 | }, 851 | { 852 | "cell_type": "code", 853 | "metadata": { 854 | "id": "I4-RpDvp2kHG", 855 | "outputId": "5438c3b5-2549-4a91-8daf-6a44cec0675a", 856 | "colab": { 857 | "base_uri": "https://localhost:8080/" 858 | } 859 | }, 860 | "source": [ 861 | "number = int(input('Enter your number: '))\n", 862 | "if number >0:\n", 863 | " print(\"Positive\")\n", 864 | "elif number < 0:\n", 865 | " print('Negative')\n", 866 | "else:\n", 867 | " print('Number is zero')" 868 | ], 869 | "execution_count": 49, 870 | "outputs": [ 871 | { 872 | "output_type": "stream", 873 | "text": [ 874 | "Enter your number: 7\n", 875 | "Positive\n" 876 | ], 877 | "name": "stdout" 878 | } 879 | ] 880 | }, 881 | { 882 | "cell_type": "markdown", 883 | "metadata": { 884 | "id": "OnJwHMUe2Ztp" 885 | }, 886 | "source": [ 887 | "**MINI CHALLENGE #5:**\n", 888 | "- **Write a code that takes a number from the user and checks if the number is divisible by 3 but is not a multiple of 7**" 889 | ] 890 | }, 891 | { 892 | "cell_type": "code", 893 | "metadata": { 894 | "id": "KHv409N93OjP", 895 | "outputId": "54777416-e51b-4bf2-f1e1-7405ac182603", 896 | "colab": { 897 | "base_uri": "https://localhost:8080/" 898 | } 899 | }, 900 | "source": [ 901 | "number = int(input('Enter your number: '))\n", 902 | "if (number % 3 == 0) and (number % 7 != 0 ):\n", 903 | " print('Number satisfies the requirements, number is divisible by 3 and not multiple of 7.')\n", 904 | "else:\n", 905 | " print('Number does not satisfy the requirements.')\n" 906 | ], 907 | "execution_count": 51, 908 | "outputs": [ 909 | { 910 | "output_type": "stream", 911 | "text": [ 912 | "Enter your number: 9\n", 913 | "Number satisfies the requirements, number is divisible by 3 and not multiple of 7.\n" 914 | ], 915 | "name": "stdout" 916 | } 917 | ] 918 | }, 919 | { 920 | "cell_type": "markdown", 921 | "metadata": { 922 | "id": "bMs3OKSo29_D" 923 | }, 924 | "source": [ 925 | "**MINI CHALLENGE #6:** \n", 926 | "- **Write a code that takes a number from the user and indicate if the number is even or odd**" 927 | ] 928 | }, 929 | { 930 | "cell_type": "code", 931 | "metadata": { 932 | "id": "RaDyZQqC28Ya", 933 | "outputId": "818bac37-4738-477b-8d9d-b1e86b812874", 934 | "colab": { 935 | "base_uri": "https://localhost:8080/" 936 | } 937 | }, 938 | "source": [ 939 | "number = int(input('Enter your number: '))\n", 940 | "if number % 2 == 0:\n", 941 | " print('Number is even')\n", 942 | "else:\n", 943 | " print('Number is odd')" 944 | ], 945 | "execution_count": 52, 946 | "outputs": [ 947 | { 948 | "output_type": "stream", 949 | "text": [ 950 | "Enter your number: 5\n", 951 | "Number is odd\n" 952 | ], 953 | "name": "stdout" 954 | } 955 | ] 956 | }, 957 | { 958 | "cell_type": "markdown", 959 | "metadata": { 960 | "id": "OHTSxeq90GFt" 961 | }, 962 | "source": [ 963 | "# MINI CHALLENGE SOLUTIONS" 964 | ] 965 | }, 966 | { 967 | "cell_type": "markdown", 968 | "metadata": { 969 | "id": "_TkjGyHolLOh" 970 | }, 971 | "source": [ 972 | "**MINI CHALLENGE #1 SOLUTION:**\n", 973 | "- **Without executing the code cell, What will this code generate?**\n", 974 | "\n", 975 | "```\n", 976 | "stock_1_price = 15\n", 977 | "stock_2_price = 10\n", 978 | "\n", 979 | "print(stock_1_price == stock_2_price) \n", 980 | "print(stock_1_price != stock_2_price) \n", 981 | "print(stock_1_price > stock_2_price)\n", 982 | "print(stock_1_price < stock_2_price) \n", 983 | "```\n" 984 | ] 985 | }, 986 | { 987 | "cell_type": "code", 988 | "metadata": { 989 | "id": "jI9I6Xv4lLOi", 990 | "outputId": "ce45f272-cf22-437b-db2f-54eedd5045f6", 991 | "colab": { 992 | "base_uri": "https://localhost:8080/", 993 | "height": 84 994 | } 995 | }, 996 | "source": [ 997 | "stock_1_price = 15\n", 998 | "stock_2_price = 10\n", 999 | "\n", 1000 | "print(stock_1_price == stock_2_price) \n", 1001 | "print(stock_1_price != stock_2_price) \n", 1002 | "print(stock_1_price > stock_2_price)\n", 1003 | "print(stock_1_price < stock_2_price) " 1004 | ], 1005 | "execution_count": null, 1006 | "outputs": [ 1007 | { 1008 | "output_type": "stream", 1009 | "text": [ 1010 | "False\n", 1011 | "True\n", 1012 | "True\n", 1013 | "False\n" 1014 | ], 1015 | "name": "stdout" 1016 | } 1017 | ] 1018 | }, 1019 | { 1020 | "cell_type": "markdown", 1021 | "metadata": { 1022 | "id": "vuw6vDPK0Jmd" 1023 | }, 1024 | "source": [ 1025 | "**MINI CHALLENGE #2 SOLUTION:**\n", 1026 | "- **Without executing the code cell, What will these two lines of code generate?**\n", 1027 | "\n", 1028 | "```\n", 1029 | "print( 'Finance'!='FINANCE' and (10 > 3) and (20 == 20)) \n", 1030 | "```\n", 1031 | "\n", 1032 | "```\n", 1033 | "print( 'Finance'!='FINANCE' or (16 > 20) or (25 == 25)) \n", 1034 | "```\n" 1035 | ] 1036 | }, 1037 | { 1038 | "cell_type": "code", 1039 | "metadata": { 1040 | "id": "gYd-N11Y0NZC", 1041 | "outputId": "a843dafa-d0d5-4ec4-c1a9-fc023604658a", 1042 | "colab": { 1043 | "base_uri": "https://localhost:8080/", 1044 | "height": 34 1045 | } 1046 | }, 1047 | "source": [ 1048 | "# FALSE and TRUE and TRUE\n", 1049 | "print('FINANCE'!='FINANCE' and (10 > 3) and (20 == 20)) " 1050 | ], 1051 | "execution_count": null, 1052 | "outputs": [ 1053 | { 1054 | "output_type": "stream", 1055 | "text": [ 1056 | "False\n" 1057 | ], 1058 | "name": "stdout" 1059 | } 1060 | ] 1061 | }, 1062 | { 1063 | "cell_type": "code", 1064 | "metadata": { 1065 | "id": "CaWri1bQ0Pys", 1066 | "outputId": "316520fa-847a-44b2-a027-ae71b2de898e", 1067 | "colab": { 1068 | "base_uri": "https://localhost:8080/", 1069 | "height": 34 1070 | } 1071 | }, 1072 | "source": [ 1073 | "# TRUE or FALSE or TRUE\n", 1074 | "print('Finance'!='FINANCE' or (16 > 20) or (25 == 25)) " 1075 | ], 1076 | "execution_count": null, 1077 | "outputs": [ 1078 | { 1079 | "output_type": "stream", 1080 | "text": [ 1081 | "True\n" 1082 | ], 1083 | "name": "stdout" 1084 | } 1085 | ] 1086 | }, 1087 | { 1088 | "cell_type": "markdown", 1089 | "metadata": { 1090 | "id": "ckRo860a1YRo" 1091 | }, 1092 | "source": [ 1093 | "**MINI CHALLENGE #3 SOLUTION:**\n", 1094 | "- **Without executing the code cell, What will these two lines of code generate?**\n", 1095 | "\n", 1096 | "```\n", 1097 | "a = 5\n", 1098 | "b = 3.5\n", 1099 | "\n", 1100 | "print(a == b or a != b) \n", 1101 | "print(a == b and a != b) \n", 1102 | "```\n" 1103 | ] 1104 | }, 1105 | { 1106 | "cell_type": "code", 1107 | "metadata": { 1108 | "id": "eFMOENhv1avh", 1109 | "outputId": "016c2b13-1cb1-401e-8832-31258dac3a7c", 1110 | "colab": { 1111 | "base_uri": "https://localhost:8080/", 1112 | "height": 50 1113 | } 1114 | }, 1115 | "source": [ 1116 | "a = 5\n", 1117 | "b = 3.5\n", 1118 | "\n", 1119 | "print(a == b or a != b) # False or True = True \n", 1120 | "print(a == b and a != b) # False and True = False" 1121 | ], 1122 | "execution_count": null, 1123 | "outputs": [ 1124 | { 1125 | "output_type": "stream", 1126 | "text": [ 1127 | "True\n", 1128 | "False\n" 1129 | ], 1130 | "name": "stdout" 1131 | } 1132 | ] 1133 | }, 1134 | { 1135 | "cell_type": "markdown", 1136 | "metadata": { 1137 | "id": "7Utj-SiU3UuK" 1138 | }, 1139 | "source": [ 1140 | "**MINI CHALLENGE #4 SOLUTION:**\n", 1141 | "- **Write a code that takes a number from the user and indicates if it's positive or negative or zero**" 1142 | ] 1143 | }, 1144 | { 1145 | "cell_type": "code", 1146 | "metadata": { 1147 | "id": "JtX7pRr03Y7r", 1148 | "outputId": "6a96004f-ee9e-4498-90cb-8e166716e890", 1149 | "colab": { 1150 | "base_uri": "https://localhost:8080/", 1151 | "height": 50 1152 | } 1153 | }, 1154 | "source": [ 1155 | "x = int(input(\"Please enter an integer: \"))\n", 1156 | "\n", 1157 | "if x < 0:\n", 1158 | " print('Number is Negative')\n", 1159 | "elif x > 0:\n", 1160 | " print('Number is Positive')\n", 1161 | "else: \n", 1162 | " print ('Number is zero')" 1163 | ], 1164 | "execution_count": null, 1165 | "outputs": [ 1166 | { 1167 | "output_type": "stream", 1168 | "text": [ 1169 | "Please enter an integer: 9\n", 1170 | "Number is Positive\n" 1171 | ], 1172 | "name": "stdout" 1173 | } 1174 | ] 1175 | }, 1176 | { 1177 | "cell_type": "markdown", 1178 | "metadata": { 1179 | "id": "4yvXX18Y3UuL" 1180 | }, 1181 | "source": [ 1182 | "**MINI CHALLENGE #5 SOLUTION:**\n", 1183 | "- **Write a code that takes a number from the user and checks if the number is divisible by 3 but is not a multiple of 7**" 1184 | ] 1185 | }, 1186 | { 1187 | "cell_type": "code", 1188 | "metadata": { 1189 | "id": "mmyi-AFc3ZLd", 1190 | "outputId": "58d90f3e-52d0-4c44-e9fd-7be93a43e2de", 1191 | "colab": { 1192 | "base_uri": "https://localhost:8080/", 1193 | "height": 50 1194 | } 1195 | }, 1196 | "source": [ 1197 | "# Try 21\n", 1198 | "\n", 1199 | "i = int(input(\"Enter a number between 1 and 100:\"))\n", 1200 | "\n", 1201 | "if (i % 3 == 0) and (i % 7 !=0):\n", 1202 | " print(\"Number satisfies the requirement; The number is divisible by 3 and not multiple of 7\")\n", 1203 | "else:\n", 1204 | " print(\"The number does not satisfy the requirements\")\n" 1205 | ], 1206 | "execution_count": null, 1207 | "outputs": [ 1208 | { 1209 | "output_type": "stream", 1210 | "text": [ 1211 | "Enter a number between 1 and 100:21\n", 1212 | "The number does not satisfy the requirements\n" 1213 | ], 1214 | "name": "stdout" 1215 | } 1216 | ] 1217 | }, 1218 | { 1219 | "cell_type": "markdown", 1220 | "metadata": { 1221 | "id": "Y-I6GMYA3UuM" 1222 | }, 1223 | "source": [ 1224 | "**MINI CHALLENGE #6 SOLUTION:** \n", 1225 | "- **Write a code that takes a number from the user and indicate if the number is even or odd**" 1226 | ] 1227 | }, 1228 | { 1229 | "cell_type": "code", 1230 | "metadata": { 1231 | "id": "VNWzhMS03Z71", 1232 | "outputId": "18804c8b-4b77-4b25-e79e-51c9aefa0fa9", 1233 | "colab": { 1234 | "base_uri": "https://localhost:8080/", 1235 | "height": 50 1236 | } 1237 | }, 1238 | "source": [ 1239 | "x = int(input(\"Please enter an integer from 1 to 1000: \"))\n", 1240 | "\n", 1241 | "if x % 2==0:\n", 1242 | " print('Number is Even')\n", 1243 | "else:\n", 1244 | " print('Number is odd')" 1245 | ], 1246 | "execution_count": null, 1247 | "outputs": [ 1248 | { 1249 | "output_type": "stream", 1250 | "text": [ 1251 | "Please enter an integer from 1 to 1000: 50\n", 1252 | "Number is Even\n" 1253 | ], 1254 | "name": "stdout" 1255 | } 1256 | ] 1257 | } 1258 | ] 1259 | } -------------------------------------------------------------------------------- /4_Python_101_For_While_Loops,_Range,_List_Comprehension_.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "4. Python 101 - For While Loops, Range, List Comprehension .ipynb", 7 | "provenance": [], 8 | "collapsed_sections": [], 9 | "include_colab_link": true 10 | }, 11 | "kernelspec": { 12 | "name": "python3", 13 | "display_name": "Python 3" 14 | } 15 | }, 16 | "cells": [ 17 | { 18 | "cell_type": "markdown", 19 | "metadata": { 20 | "id": "view-in-github", 21 | "colab_type": "text" 22 | }, 23 | "source": [ 24 | "\"Open" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": { 30 | "id": "BK5uIrxoLRtf" 31 | }, 32 | "source": [ 33 | "# 1. FOR LOOPS" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "metadata": { 39 | "id": "IeM5ykmzHuYB", 40 | "outputId": "4c1b7375-efb9-400b-a6e0-e4f32d567c6e", 41 | "colab": { 42 | "base_uri": "https://localhost:8080/" 43 | } 44 | }, 45 | "source": [ 46 | "# For loops are used for iterating over a sequence (a list, a tuple, a dictionary, a set, or a string).\n", 47 | "# An action can be executed once for each item in a list, tuple of the for loop.\n", 48 | "\n", 49 | "my_list = [1, 2, 3]\n", 50 | "for i in my_list:\n", 51 | " print(i)\n" 52 | ], 53 | "execution_count": null, 54 | "outputs": [ 55 | { 56 | "output_type": "stream", 57 | "text": [ 58 | "1\n", 59 | "2\n", 60 | "3\n" 61 | ], 62 | "name": "stdout" 63 | } 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "metadata": { 69 | "id": "R0jpLRvsJ4Yf", 70 | "outputId": "ccac14a5-6f4e-448a-b955-ca715e73ccae", 71 | "colab": { 72 | "base_uri": "https://localhost:8080/" 73 | } 74 | }, 75 | "source": [ 76 | "my_tuple = (2, 3, 4, 5)\n", 77 | "for i in my_tuple:\n", 78 | " print(i)" 79 | ], 80 | "execution_count": null, 81 | "outputs": [ 82 | { 83 | "output_type": "stream", 84 | "text": [ 85 | "2\n", 86 | "3\n", 87 | "4\n", 88 | "5\n" 89 | ], 90 | "name": "stdout" 91 | } 92 | ] 93 | }, 94 | { 95 | "cell_type": "code", 96 | "metadata": { 97 | "id": "a5dXYSWBJ5Ze", 98 | "outputId": "4e4875fb-6279-4700-e761-064faae34db4", 99 | "colab": { 100 | "base_uri": "https://localhost:8080/" 101 | } 102 | }, 103 | "source": [ 104 | "# you can do more than one task for every loop such as printing out 'Hello world' \n", 105 | "\n", 106 | "for i in my_list:\n", 107 | " print(i)\n", 108 | " print('Hello world')\n" 109 | ], 110 | "execution_count": null, 111 | "outputs": [ 112 | { 113 | "output_type": "stream", 114 | "text": [ 115 | "1\n", 116 | "Hello world\n", 117 | "2\n", 118 | "Hello world\n", 119 | "3\n", 120 | "Hello world\n" 121 | ], 122 | "name": "stdout" 123 | } 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "metadata": { 129 | "id": "q76leWB9J5bx", 130 | "outputId": "16c0999c-2602-4ca5-a72b-4d75865193e1", 131 | "colab": { 132 | "base_uri": "https://localhost:8080/" 133 | } 134 | }, 135 | "source": [ 136 | "# List of strings\n", 137 | "\n", 138 | "my_list = ['AAPL', 'GOOG', 'T', 'TSLA', 'TS500']\n", 139 | "my_list" 140 | ], 141 | "execution_count": null, 142 | "outputs": [ 143 | { 144 | "output_type": "execute_result", 145 | "data": { 146 | "text/plain": [ 147 | "['AAPL', 'GOOG', 'T', 'TSLA', 'TS500']" 148 | ] 149 | }, 150 | "metadata": { 151 | "tags": [] 152 | }, 153 | "execution_count": 6 154 | } 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "metadata": { 160 | "id": "DD9E3VLPJ5fo", 161 | "outputId": "cee03702-46b9-42e1-9613-cef59cec0e71", 162 | "colab": { 163 | "base_uri": "https://localhost:8080/" 164 | } 165 | }, 166 | "source": [ 167 | "for i in my_list:\n", 168 | " print(i)" 169 | ], 170 | "execution_count": null, 171 | "outputs": [ 172 | { 173 | "output_type": "stream", 174 | "text": [ 175 | "AAPL\n", 176 | "GOOG\n", 177 | "T\n", 178 | "TSLA\n", 179 | "TS500\n" 180 | ], 181 | "name": "stdout" 182 | } 183 | ] 184 | }, 185 | { 186 | "cell_type": "code", 187 | "metadata": { 188 | "id": "2QI7iU17J5j_", 189 | "outputId": "99854a0a-1fe6-4041-9e0d-7048cce2a1a2", 190 | "colab": { 191 | "base_uri": "https://localhost:8080/" 192 | } 193 | }, 194 | "source": [ 195 | "# you can loop over a string as follows\n", 196 | "\n", 197 | "for i in 'TSLA':\n", 198 | " print(i)" 199 | ], 200 | "execution_count": null, 201 | "outputs": [ 202 | { 203 | "output_type": "stream", 204 | "text": [ 205 | "T\n", 206 | "S\n", 207 | "L\n", 208 | "A\n" 209 | ], 210 | "name": "stdout" 211 | } 212 | ] 213 | }, 214 | { 215 | "cell_type": "markdown", 216 | "metadata": { 217 | "id": "VHeLtXS0Z5XU" 218 | }, 219 | "source": [ 220 | "**MINI CHALLENGE #1:**\n", 221 | "- **Write a code that takes in a string and prints it out on the screen except for any letter 'T'. You can replace the letter 'T' with '*'.**" 222 | ] 223 | }, 224 | { 225 | "cell_type": "code", 226 | "metadata": { 227 | "id": "b_NU7mBfa-SB", 228 | "outputId": "e0759154-523d-447c-b8e9-76cc0a169eba", 229 | "colab": { 230 | "base_uri": "https://localhost:8080/" 231 | } 232 | }, 233 | "source": [ 234 | "my_string = 'TSLA'\n", 235 | "for i in 'TSLA':\n", 236 | " if i == 'T':\n", 237 | " print('*')\n", 238 | " else:\n", 239 | " print(i)" 240 | ], 241 | "execution_count": null, 242 | "outputs": [ 243 | { 244 | "output_type": "stream", 245 | "text": [ 246 | "*\n", 247 | "S\n", 248 | "L\n", 249 | "A\n" 250 | ], 251 | "name": "stdout" 252 | } 253 | ] 254 | }, 255 | { 256 | "cell_type": "markdown", 257 | "metadata": { 258 | "id": "5ShxNDJeLVVo" 259 | }, 260 | "source": [ 261 | "# 2. RANGE" 262 | ] 263 | }, 264 | { 265 | "cell_type": "code", 266 | "metadata": { 267 | "id": "fsH8H4IwJ5mi" 268 | }, 269 | "source": [ 270 | "# Range() generates a list of numbers, which is used to iterate over with for loops.\n", 271 | "# range() is 0-index based, meaning list indexes start at 0, not 1. \n", 272 | "# The last integer generated by range() is up to, but not including, last element. \n", 273 | "# Example: range(0, 10) generates integers from 0 up to, but not including, 10." 274 | ], 275 | "execution_count": null, 276 | "outputs": [] 277 | }, 278 | { 279 | "cell_type": "code", 280 | "metadata": { 281 | "id": "LfnqYODNJ5qq", 282 | "outputId": "1ba81da4-6932-4fcd-9f28-90a80677dbc6", 283 | "colab": { 284 | "base_uri": "https://localhost:8080/" 285 | } 286 | }, 287 | "source": [ 288 | "for i in range(6):\n", 289 | " print(i)" 290 | ], 291 | "execution_count": null, 292 | "outputs": [ 293 | { 294 | "output_type": "stream", 295 | "text": [ 296 | "0\n", 297 | "1\n", 298 | "2\n", 299 | "3\n", 300 | "4\n", 301 | "5\n" 302 | ], 303 | "name": "stdout" 304 | } 305 | ] 306 | }, 307 | { 308 | "cell_type": "code", 309 | "metadata": { 310 | "id": "b4XBIA2KJ5pT", 311 | "outputId": "0f1a9dc7-3d31-4b2c-9ac6-b21c952f5f15", 312 | "colab": { 313 | "base_uri": "https://localhost:8080/" 314 | } 315 | }, 316 | "source": [ 317 | "# Range of numbers from 1 to 20 with steps of 2\n", 318 | "\n", 319 | "for i in range(1, 20, 2):\n", 320 | " print(i)" 321 | ], 322 | "execution_count": null, 323 | "outputs": [ 324 | { 325 | "output_type": "stream", 326 | "text": [ 327 | "1\n", 328 | "3\n", 329 | "5\n", 330 | "7\n", 331 | "9\n", 332 | "11\n", 333 | "13\n", 334 | "15\n", 335 | "17\n", 336 | "19\n" 337 | ], 338 | "name": "stdout" 339 | } 340 | ] 341 | }, 342 | { 343 | "cell_type": "code", 344 | "metadata": { 345 | "id": "dOpRLPUNJ5iO", 346 | "outputId": "9a113dee-f434-44c6-d22e-e58fd2cc75ac", 347 | "colab": { 348 | "base_uri": "https://localhost:8080/" 349 | } 350 | }, 351 | "source": [ 352 | "for i in reversed(range(5)):\n", 353 | " print(i)" 354 | ], 355 | "execution_count": null, 356 | "outputs": [ 357 | { 358 | "output_type": "stream", 359 | "text": [ 360 | "4\n", 361 | "3\n", 362 | "2\n", 363 | "1\n", 364 | "0\n" 365 | ], 366 | "name": "stdout" 367 | } 368 | ] 369 | }, 370 | { 371 | "cell_type": "markdown", 372 | "metadata": { 373 | "id": "eRgAw_bLbNBj" 374 | }, 375 | "source": [ 376 | "**MINI CHALLENGE #2:**\n", 377 | "- **Write a code that takes in the maximum and minimum limits from the user and prints out even numbers only between the provided range**" 378 | ] 379 | }, 380 | { 381 | "cell_type": "code", 382 | "metadata": { 383 | "id": "TzPMQq-obcAI", 384 | "outputId": "b8ceabf7-95a1-407b-aa79-c89f037d6bf9", 385 | "colab": { 386 | "base_uri": "https://localhost:8080/" 387 | } 388 | }, 389 | "source": [ 390 | "\n", 391 | "user_min = int(input(\"Enter min number.\"))\n", 392 | "user_max = int(input('Enter max number.'))\n", 393 | "\n", 394 | "for i in range(user_min, user_max):\n", 395 | " if i % 2 == 0:\n", 396 | " print(i)" 397 | ], 398 | "execution_count": null, 399 | "outputs": [ 400 | { 401 | "output_type": "stream", 402 | "text": [ 403 | "Enter max number.7\n", 404 | "Enter min number.0\n", 405 | "0\n", 406 | "2\n", 407 | "4\n", 408 | "6\n" 409 | ], 410 | "name": "stdout" 411 | } 412 | ] 413 | }, 414 | { 415 | "cell_type": "markdown", 416 | "metadata": { 417 | "id": "KoBeo2-NW-IG" 418 | }, 419 | "source": [ 420 | "**MINI CHALLENGE #3:**\n", 421 | "- **Write a code that generates the following table:**\n", 422 | "```\n", 423 | "1 1 1\n", 424 | "2 4 8\n", 425 | "3 9 27\n", 426 | "4 16 64\n", 427 | "5 25 125\n", 428 | "6 36 216\n", 429 | "7 49 343\n", 430 | "8 64 512\n", 431 | "9 81 729\n", 432 | "10 100 1000\n", 433 | "```\n", 434 | "\n", 435 | "\n" 436 | ] 437 | }, 438 | { 439 | "cell_type": "code", 440 | "metadata": { 441 | "id": "sgmgClBDN-x5", 442 | "outputId": "5cabbdb3-0da3-40d5-91bc-b10b7b02f80a", 443 | "colab": { 444 | "base_uri": "https://localhost:8080/" 445 | } 446 | }, 447 | "source": [ 448 | "for i in range(1, 11):\n", 449 | " print(f'{i} {i*i} {i*i*i}')" 450 | ], 451 | "execution_count": null, 452 | "outputs": [ 453 | { 454 | "output_type": "stream", 455 | "text": [ 456 | "1 1 1\n", 457 | "2 4 8\n", 458 | "3 9 27\n", 459 | "4 16 64\n", 460 | "5 25 125\n", 461 | "6 36 216\n", 462 | "7 49 343\n", 463 | "8 64 512\n", 464 | "9 81 729\n", 465 | "10 100 1000\n" 466 | ], 467 | "name": "stdout" 468 | } 469 | ] 470 | }, 471 | { 472 | "cell_type": "markdown", 473 | "metadata": { 474 | "id": "7xt72C8NNgN8" 475 | }, 476 | "source": [ 477 | "# 3. WHILE LOOPS" 478 | ] 479 | }, 480 | { 481 | "cell_type": "code", 482 | "metadata": { 483 | "id": "G1Du3nteNlfR", 484 | "outputId": "b412e41a-e3b5-4f86-fee6-4d7e1577b4a1", 485 | "colab": { 486 | "base_uri": "https://localhost:8080/" 487 | } 488 | }, 489 | "source": [ 490 | "# While loop can be used to execute a set of statements as long as a certain condition holds true.\n", 491 | "\n", 492 | "i = 0 \n", 493 | "while i<= 10:\n", 494 | " print(i)\n", 495 | " i+=1\n" 496 | ], 497 | "execution_count": null, 498 | "outputs": [ 499 | { 500 | "output_type": "stream", 501 | "text": [ 502 | "0\n", 503 | "1\n", 504 | "2\n", 505 | "3\n", 506 | "4\n", 507 | "5\n", 508 | "6\n", 509 | "7\n", 510 | "8\n", 511 | "9\n", 512 | "10\n" 513 | ], 514 | "name": "stdout" 515 | } 516 | ] 517 | }, 518 | { 519 | "cell_type": "code", 520 | "metadata": { 521 | "id": "z0sUEdgvNoFe", 522 | "outputId": "2fbe6225-b8f1-4324-a42e-eece68b66f1e", 523 | "colab": { 524 | "base_uri": "https://localhost:8080/" 525 | } 526 | }, 527 | "source": [ 528 | "i = 0 \n", 529 | "while i<8:\n", 530 | " print(i)\n", 531 | " i+=2" 532 | ], 533 | "execution_count": null, 534 | "outputs": [ 535 | { 536 | "output_type": "stream", 537 | "text": [ 538 | "0\n", 539 | "2\n", 540 | "4\n", 541 | "6\n" 542 | ], 543 | "name": "stdout" 544 | } 545 | ] 546 | }, 547 | { 548 | "cell_type": "markdown", 549 | "metadata": { 550 | "id": "lB2soXiSUWDd" 551 | }, 552 | "source": [ 553 | "**MINI CHALLENGE #4:**\n", 554 | "- **Write a code that displays numbers from 1 to 30 using for and while loops**\n" 555 | ] 556 | }, 557 | { 558 | "cell_type": "code", 559 | "metadata": { 560 | "id": "RY_3xRVRXWuL", 561 | "outputId": "3fbd9407-9a4e-4bf6-a8b7-fc6b43a63f34", 562 | "colab": { 563 | "base_uri": "https://localhost:8080/" 564 | } 565 | }, 566 | "source": [ 567 | "for i in range(1, 31):\n", 568 | " print(i)" 569 | ], 570 | "execution_count": null, 571 | "outputs": [ 572 | { 573 | "output_type": "stream", 574 | "text": [ 575 | "1\n", 576 | "2\n", 577 | "3\n", 578 | "4\n", 579 | "5\n", 580 | "6\n", 581 | "7\n", 582 | "8\n", 583 | "9\n", 584 | "10\n", 585 | "11\n", 586 | "12\n", 587 | "13\n", 588 | "14\n", 589 | "15\n", 590 | "16\n", 591 | "17\n", 592 | "18\n", 593 | "19\n", 594 | "20\n", 595 | "21\n", 596 | "22\n", 597 | "23\n", 598 | "24\n", 599 | "25\n", 600 | "26\n", 601 | "27\n", 602 | "28\n", 603 | "29\n", 604 | "30\n" 605 | ], 606 | "name": "stdout" 607 | } 608 | ] 609 | }, 610 | { 611 | "cell_type": "code", 612 | "metadata": { 613 | "id": "ZRg_l0C14dF8", 614 | "outputId": "b51ffd6a-93ab-4229-8324-df643e80342a", 615 | "colab": { 616 | "base_uri": "https://localhost:8080/" 617 | } 618 | }, 619 | "source": [ 620 | "i = 1\n", 621 | "while i <=30:\n", 622 | " print(i)\n", 623 | " i+=1" 624 | ], 625 | "execution_count": null, 626 | "outputs": [ 627 | { 628 | "output_type": "stream", 629 | "text": [ 630 | "1\n", 631 | "2\n", 632 | "3\n", 633 | "4\n", 634 | "5\n", 635 | "6\n", 636 | "7\n", 637 | "8\n", 638 | "9\n", 639 | "10\n", 640 | "11\n", 641 | "12\n", 642 | "13\n", 643 | "14\n", 644 | "15\n", 645 | "16\n", 646 | "17\n", 647 | "18\n", 648 | "19\n", 649 | "20\n", 650 | "21\n", 651 | "22\n", 652 | "23\n", 653 | "24\n", 654 | "25\n", 655 | "26\n", 656 | "27\n", 657 | "28\n", 658 | "29\n", 659 | "30\n" 660 | ], 661 | "name": "stdout" 662 | } 663 | ] 664 | }, 665 | { 666 | "cell_type": "markdown", 667 | "metadata": { 668 | "id": "ZIueG9h3XXTC" 669 | }, 670 | "source": [ 671 | "**MINI CHALLENGE #5:**\n", 672 | "- **Create a rolling dice game that assume we have two dice (#1 and #2). The dice is being thrown and a random number is generated everytime. The game should be designed such that it prompts the user to ask if he/she would like to keep playing or exit the game.**" 673 | ] 674 | }, 675 | { 676 | "cell_type": "code", 677 | "metadata": { 678 | "id": "e5lIJV7KnV9W", 679 | "outputId": "2acedcb4-22e7-48f3-88be-0b18e8679a56", 680 | "colab": { 681 | "base_uri": "https://localhost:8080/" 682 | } 683 | }, 684 | "source": [ 685 | "import random\n", 686 | "\n", 687 | "keep_rolling = 'y'\n", 688 | "\n", 689 | "while keep_rolling == 'y':\n", 690 | " print('We are rolling the dice now...')\n", 691 | " dice_1 = random.randint(1, 6)\n", 692 | " print(f'dice 1: {dice_1}')\n", 693 | " dice_2 = random.randint(1, 6)\n", 694 | " print(f'dice 2: {dice_2}')\n", 695 | "\n", 696 | " keep_rolling = input('Do you want to rall again?')\n" 697 | ], 698 | "execution_count": null, 699 | "outputs": [ 700 | { 701 | "output_type": "stream", 702 | "text": [ 703 | "We are rolling the dice now...\n", 704 | "dice 1: 6\n", 705 | "dice 2: 6\n", 706 | "Do you want to rall again?y\n", 707 | "We are rolling the dice now...\n", 708 | "dice 1: 4\n", 709 | "dice 2: 2\n", 710 | "Do you want to rall again?y\n", 711 | "We are rolling the dice now...\n", 712 | "dice 1: 6\n", 713 | "dice 2: 5\n", 714 | "Do you want to rall again?n\n" 715 | ], 716 | "name": "stdout" 717 | } 718 | ] 719 | }, 720 | { 721 | "cell_type": "markdown", 722 | "metadata": { 723 | "id": "9wunXtl0M9sT" 724 | }, 725 | "source": [ 726 | "# 4. BREAK A LOOP" 727 | ] 728 | }, 729 | { 730 | "cell_type": "code", 731 | "metadata": { 732 | "id": "Zl8mvmT3J5eY" 733 | }, 734 | "source": [ 735 | "# break() is used to exit a for loop or a while loop\n", 736 | "# continue() is used to skip the current block, and return to the \"for\" or \"while\" statement." 737 | ], 738 | "execution_count": null, 739 | "outputs": [] 740 | }, 741 | { 742 | "cell_type": "code", 743 | "metadata": { 744 | "id": "mYbZR3i6NH8k" 745 | }, 746 | "source": [ 747 | "my_list = ['GOOG', 'AAPL', 'T', 'TSLA', 'SP500']" 748 | ], 749 | "execution_count": null, 750 | "outputs": [] 751 | }, 752 | { 753 | "cell_type": "code", 754 | "metadata": { 755 | "id": "P0gbDVWVNMzw", 756 | "outputId": "d78bb493-122d-48a8-c0bf-23cb0d786fec", 757 | "colab": { 758 | "base_uri": "https://localhost:8080/" 759 | } 760 | }, 761 | "source": [ 762 | "my_list" 763 | ], 764 | "execution_count": null, 765 | "outputs": [ 766 | { 767 | "output_type": "execute_result", 768 | "data": { 769 | "text/plain": [ 770 | "['GOOG', 'AAPL', 'T', 'TSLA', 'SP500']" 771 | ] 772 | }, 773 | "metadata": { 774 | "tags": [] 775 | }, 776 | "execution_count": 9 777 | } 778 | ] 779 | }, 780 | { 781 | "cell_type": "code", 782 | "metadata": { 783 | "id": "JGerA93sNM4C", 784 | "outputId": "aab366a6-f502-4a64-8bc1-96bc6d066cde", 785 | "colab": { 786 | "base_uri": "https://localhost:8080/" 787 | } 788 | }, 789 | "source": [ 790 | "# print out all elements in the list\n", 791 | "\n", 792 | "for i in my_list:\n", 793 | " print(i)" 794 | ], 795 | "execution_count": null, 796 | "outputs": [ 797 | { 798 | "output_type": "stream", 799 | "text": [ 800 | "GOOG\n", 801 | "AAPL\n", 802 | "T\n", 803 | "TSLA\n", 804 | "SP500\n" 805 | ], 806 | "name": "stdout" 807 | } 808 | ] 809 | }, 810 | { 811 | "cell_type": "code", 812 | "metadata": { 813 | "id": "7gsSn9R9NNBH", 814 | "outputId": "423c17ab-384f-42e0-d227-712119ea4569", 815 | "colab": { 816 | "base_uri": "https://localhost:8080/" 817 | } 818 | }, 819 | "source": [ 820 | "# print out all elements in the list up until the AT&T stock (Ticker Symbol = T) is detected\n", 821 | " \n", 822 | "for i in my_list:\n", 823 | " print(i)\n", 824 | " if i == 'T':\n", 825 | " break" 826 | ], 827 | "execution_count": null, 828 | "outputs": [ 829 | { 830 | "output_type": "stream", 831 | "text": [ 832 | "GOOG\n", 833 | "AAPL\n", 834 | "T\n" 835 | ], 836 | "name": "stdout" 837 | } 838 | ] 839 | }, 840 | { 841 | "cell_type": "code", 842 | "metadata": { 843 | "id": "Rja3f7RiNM_F", 844 | "outputId": "012d29db-4b00-4df8-daf4-74bd1f4a7afb", 845 | "colab": { 846 | "base_uri": "https://localhost:8080/" 847 | } 848 | }, 849 | "source": [ 850 | "# Print only odd elements and skip even numbers\n", 851 | "\n", 852 | "my_list = [1, 2 , 3, 4, 5, 6, 7, 8, 9, 10]\n", 853 | "\n", 854 | "for i in my_list:\n", 855 | " if i % 2 == 0:\n", 856 | " continue\n", 857 | " print(i)" 858 | ], 859 | "execution_count": null, 860 | "outputs": [ 861 | { 862 | "output_type": "stream", 863 | "text": [ 864 | "1\n", 865 | "3\n", 866 | "5\n", 867 | "7\n", 868 | "9\n" 869 | ], 870 | "name": "stdout" 871 | } 872 | ] 873 | }, 874 | { 875 | "cell_type": "markdown", 876 | "metadata": { 877 | "id": "JF9CljMnYwEi" 878 | }, 879 | "source": [ 880 | "**MINI CHALLENGE #6:**\n", 881 | "- **Write a code that continiously gets data from the user and calculates the average and print out on the screen. The code exits when the user enters 'e'.**" 882 | ] 883 | }, 884 | { 885 | "cell_type": "code", 886 | "metadata": { 887 | "id": "ynWaFl9LoIjw", 888 | "outputId": "2b296df8-fc6d-4254-e5fc-75064034ce2b", 889 | "colab": { 890 | "base_uri": "https://localhost:8080/" 891 | } 892 | }, 893 | "source": [ 894 | "keep_rolling = 'y'\n", 895 | "count = 0\n", 896 | "sum = 0\n", 897 | "average = 0\n", 898 | "\n", 899 | "while keep_rolling == 'y':\n", 900 | " user_number = int(input(\"Enter your number...\"))\n", 901 | " count+=1\n", 902 | " sum += user_number\n", 903 | " average = sum/count\n", 904 | " print(f\"average is: {round(average, 2)}\")\n", 905 | "\n", 906 | " keep_rolling = input('Do you want to add number again?')" 907 | ], 908 | "execution_count": null, 909 | "outputs": [ 910 | { 911 | "output_type": "stream", 912 | "text": [ 913 | "Enter your number...45\n", 914 | "average is: 45.0\n", 915 | "Do you want to add number again?y\n", 916 | "Enter your number...3\n", 917 | "average is: 24.0\n", 918 | "Do you want to add number again?43\n" 919 | ], 920 | "name": "stdout" 921 | } 922 | ] 923 | }, 924 | { 925 | "cell_type": "code", 926 | "metadata": { 927 | "id": "p_Rr8JTO9kxe", 928 | "outputId": "1ed99905-e3cb-46cb-c2ff-dbb2ecfc49ab", 929 | "colab": { 930 | "base_uri": "https://localhost:8080/" 931 | } 932 | }, 933 | "source": [ 934 | "avg = 0\n", 935 | "n = 0\n", 936 | "\n", 937 | "while True:\n", 938 | " x = input('Enter a number...')\n", 939 | "\n", 940 | " if x == 'e':\n", 941 | " break\n", 942 | "\n", 943 | " x = int(x)\n", 944 | " n +=1\n", 945 | "\n", 946 | " avg = (avg * (n-1) + x) / n\n", 947 | " print(f'The current average is {avg}')\n", 948 | "\n" 949 | ], 950 | "execution_count": 2, 951 | "outputs": [ 952 | { 953 | "output_type": "stream", 954 | "text": [ 955 | "Enter a number...67\n", 956 | "The current average is 67.0\n", 957 | "Enter a number...89\n", 958 | "The current average is 78.0\n", 959 | "Enter a number...600\n", 960 | "The current average is 252.0\n", 961 | "Enter a number...50\n", 962 | "The current average is 201.5\n", 963 | "Enter a number...e\n" 964 | ], 965 | "name": "stdout" 966 | } 967 | ] 968 | }, 969 | { 970 | "cell_type": "markdown", 971 | "metadata": { 972 | "id": "22kF_RupOG2o" 973 | }, 974 | "source": [ 975 | "# 5. NESTED LOOPS" 976 | ] 977 | }, 978 | { 979 | "cell_type": "code", 980 | "metadata": { 981 | "id": "rL6xaGIbNM69", 982 | "outputId": "4d984cc3-8aeb-434a-a35a-a8fb4cac18b6", 983 | "colab": { 984 | "base_uri": "https://localhost:8080/" 985 | } 986 | }, 987 | "source": [ 988 | "# Nested loops are loops that exist inside the body of another loop\n", 989 | "\n", 990 | "for x in range(1,4):\n", 991 | " for y in range(1,11):\n", 992 | " print(f\"{x} * {y} = {x*y}\")" 993 | ], 994 | "execution_count": 4, 995 | "outputs": [ 996 | { 997 | "output_type": "stream", 998 | "text": [ 999 | "1 * 1 = 1\n", 1000 | "1 * 2 = 2\n", 1001 | "1 * 3 = 3\n", 1002 | "1 * 4 = 4\n", 1003 | "1 * 5 = 5\n", 1004 | "1 * 6 = 6\n", 1005 | "1 * 7 = 7\n", 1006 | "1 * 8 = 8\n", 1007 | "1 * 9 = 9\n", 1008 | "1 * 10 = 10\n", 1009 | "2 * 1 = 2\n", 1010 | "2 * 2 = 4\n", 1011 | "2 * 3 = 6\n", 1012 | "2 * 4 = 8\n", 1013 | "2 * 5 = 10\n", 1014 | "2 * 6 = 12\n", 1015 | "2 * 7 = 14\n", 1016 | "2 * 8 = 16\n", 1017 | "2 * 9 = 18\n", 1018 | "2 * 10 = 20\n", 1019 | "3 * 1 = 3\n", 1020 | "3 * 2 = 6\n", 1021 | "3 * 3 = 9\n", 1022 | "3 * 4 = 12\n", 1023 | "3 * 5 = 15\n", 1024 | "3 * 6 = 18\n", 1025 | "3 * 7 = 21\n", 1026 | "3 * 8 = 24\n", 1027 | "3 * 9 = 27\n", 1028 | "3 * 10 = 30\n" 1029 | ], 1030 | "name": "stdout" 1031 | } 1032 | ] 1033 | }, 1034 | { 1035 | "cell_type": "code", 1036 | "metadata": { 1037 | "id": "Xpe6MiCiNM2L", 1038 | "outputId": "89734c38-2661-45c7-b14b-21cb26e82fa1", 1039 | "colab": { 1040 | "base_uri": "https://localhost:8080/" 1041 | } 1042 | }, 1043 | "source": [ 1044 | "color_list = ['black', 'white', 'gold']\n", 1045 | "phone_list = ['iphone', 'samsung', 'blackbarry']\n", 1046 | "\n", 1047 | "for i in color_list:\n", 1048 | " for j in phone_list:\n", 1049 | " print(i, j)" 1050 | ], 1051 | "execution_count": 5, 1052 | "outputs": [ 1053 | { 1054 | "output_type": "stream", 1055 | "text": [ 1056 | "black iphone\n", 1057 | "black samsung\n", 1058 | "black blackbarry\n", 1059 | "white iphone\n", 1060 | "white samsung\n", 1061 | "white blackbarry\n", 1062 | "gold iphone\n", 1063 | "gold samsung\n", 1064 | "gold blackbarry\n" 1065 | ], 1066 | "name": "stdout" 1067 | } 1068 | ] 1069 | }, 1070 | { 1071 | "cell_type": "markdown", 1072 | "metadata": { 1073 | "id": "r9D5aZhAfa-O" 1074 | }, 1075 | "source": [ 1076 | "**MINI CHALLENGE #7:**\n", 1077 | "- **Write a code that takes in a number (range between 1 and 9) from the user and print out the multiplication table up until that number.**" 1078 | ] 1079 | }, 1080 | { 1081 | "cell_type": "code", 1082 | "metadata": { 1083 | "id": "LD-wO03co0QI", 1084 | "outputId": "22dc60bf-d2d7-46f5-f5bb-05358bbd66db", 1085 | "colab": { 1086 | "base_uri": "https://localhost:8080/" 1087 | } 1088 | }, 1089 | "source": [ 1090 | "user_number = int(input('Enter a number from 1 to 9: '))\n", 1091 | "\n", 1092 | "for i in range(1, user_number+1):\n", 1093 | " for j in range(1, user_number+1):\n", 1094 | " print(f\"{i} * {j} = {i*j}\")" 1095 | ], 1096 | "execution_count": 8, 1097 | "outputs": [ 1098 | { 1099 | "output_type": "stream", 1100 | "text": [ 1101 | "Enter a number from 1 to 9: 5\n", 1102 | "1 * 1 = 1\n", 1103 | "1 * 2 = 2\n", 1104 | "1 * 3 = 3\n", 1105 | "1 * 4 = 4\n", 1106 | "1 * 5 = 5\n", 1107 | "2 * 1 = 2\n", 1108 | "2 * 2 = 4\n", 1109 | "2 * 3 = 6\n", 1110 | "2 * 4 = 8\n", 1111 | "2 * 5 = 10\n", 1112 | "3 * 1 = 3\n", 1113 | "3 * 2 = 6\n", 1114 | "3 * 3 = 9\n", 1115 | "3 * 4 = 12\n", 1116 | "3 * 5 = 15\n", 1117 | "4 * 1 = 4\n", 1118 | "4 * 2 = 8\n", 1119 | "4 * 3 = 12\n", 1120 | "4 * 4 = 16\n", 1121 | "4 * 5 = 20\n", 1122 | "5 * 1 = 5\n", 1123 | "5 * 2 = 10\n", 1124 | "5 * 3 = 15\n", 1125 | "5 * 4 = 20\n", 1126 | "5 * 5 = 25\n" 1127 | ], 1128 | "name": "stdout" 1129 | } 1130 | ] 1131 | }, 1132 | { 1133 | "cell_type": "markdown", 1134 | "metadata": { 1135 | "id": "2-WphsjVPDiZ" 1136 | }, 1137 | "source": [ 1138 | "# 6. LIST COMPREHENSION" 1139 | ] 1140 | }, 1141 | { 1142 | "cell_type": "code", 1143 | "metadata": { 1144 | "id": "qz9csDMHPNWA", 1145 | "outputId": "cf4d30ab-1978-4140-d28c-32849248b1de", 1146 | "colab": { 1147 | "base_uri": "https://localhost:8080/" 1148 | } 1149 | }, 1150 | "source": [ 1151 | "# List comprehension is an elegant tool to transform one list into another list. \n", 1152 | "# Instead of using loops and append, list comprehension is used to iterate over a list, condition its elements and include them in a new list.\n", 1153 | "# Let's take a look at the traditional way of taking a list and squaring its elements\n", 1154 | "\n", 1155 | "input_list = [1,2,3,4]\n", 1156 | "output_list = []\n", 1157 | "\n", 1158 | "for element in input_list:\n", 1159 | " output_list.append(element ** 2)\n", 1160 | "\n", 1161 | "output_list \n" 1162 | ], 1163 | "execution_count": 2, 1164 | "outputs": [ 1165 | { 1166 | "output_type": "execute_result", 1167 | "data": { 1168 | "text/plain": [ 1169 | "[1, 4, 9, 16]" 1170 | ] 1171 | }, 1172 | "metadata": { 1173 | "tags": [] 1174 | }, 1175 | "execution_count": 2 1176 | } 1177 | ] 1178 | }, 1179 | { 1180 | "cell_type": "code", 1181 | "metadata": { 1182 | "id": "vw-8Z7adPdTP", 1183 | "outputId": "3d5c1d4a-3676-4cc3-d740-85f0d7ecea5e", 1184 | "colab": { 1185 | "base_uri": "https://localhost:8080/" 1186 | } 1187 | }, 1188 | "source": [ 1189 | "# List comprehension is a super powerful one line of code!\n", 1190 | "\n", 1191 | "[element ** 2 for element in input_list]" 1192 | ], 1193 | "execution_count": 3, 1194 | "outputs": [ 1195 | { 1196 | "output_type": "execute_result", 1197 | "data": { 1198 | "text/plain": [ 1199 | "[1, 4, 9, 16]" 1200 | ] 1201 | }, 1202 | "metadata": { 1203 | "tags": [] 1204 | }, 1205 | "execution_count": 3 1206 | } 1207 | ] 1208 | }, 1209 | { 1210 | "cell_type": "code", 1211 | "metadata": { 1212 | "id": "az-FlBJsPwRh", 1213 | "outputId": "030a8723-9fd8-4a15-b7b9-84cbbfb4283a", 1214 | "colab": { 1215 | "base_uri": "https://localhost:8080/" 1216 | } 1217 | }, 1218 | "source": [ 1219 | "# Let's square even numbers only \n", 1220 | "# We need to insert a condition \n", 1221 | "\n", 1222 | "input_list = [1,2,3,4,5,6,7,8,9,10]\n", 1223 | "output_list = []\n", 1224 | "\n", 1225 | "for i in input_list:\n", 1226 | " if i % 2 == 0:\n", 1227 | " output_list.append(i ** 2)\n", 1228 | "\n", 1229 | "output_list\n" 1230 | ], 1231 | "execution_count": 4, 1232 | "outputs": [ 1233 | { 1234 | "output_type": "execute_result", 1235 | "data": { 1236 | "text/plain": [ 1237 | "[4, 16, 36, 64, 100]" 1238 | ] 1239 | }, 1240 | "metadata": { 1241 | "tags": [] 1242 | }, 1243 | "execution_count": 4 1244 | } 1245 | ] 1246 | }, 1247 | { 1248 | "cell_type": "code", 1249 | "metadata": { 1250 | "id": "zaREccpfP47m", 1251 | "outputId": "434cf0f5-93d9-4b30-d867-a92bea65facc", 1252 | "colab": { 1253 | "base_uri": "https://localhost:8080/" 1254 | } 1255 | }, 1256 | "source": [ 1257 | "# All this could be done with one line of code as well using List Comprehension\n", 1258 | "\n", 1259 | "output_list = [ i ** 2 for i in input_list if i % 2 == 0]\n", 1260 | "output_list\n" 1261 | ], 1262 | "execution_count": 6, 1263 | "outputs": [ 1264 | { 1265 | "output_type": "execute_result", 1266 | "data": { 1267 | "text/plain": [ 1268 | "[4, 16, 36, 64, 100]" 1269 | ] 1270 | }, 1271 | "metadata": { 1272 | "tags": [] 1273 | }, 1274 | "execution_count": 6 1275 | } 1276 | ] 1277 | }, 1278 | { 1279 | "cell_type": "markdown", 1280 | "metadata": { 1281 | "id": "lIBSXypYX_3O" 1282 | }, 1283 | "source": [ 1284 | "**MINI CHALLENGE #8:**\n", 1285 | "- **Write a code that takes in a list of prices of a stock for the past 7 days and then normalize the prices** " 1286 | ] 1287 | }, 1288 | { 1289 | "cell_type": "code", 1290 | "metadata": { 1291 | "id": "02iEvxCQQyZ7", 1292 | "outputId": "7905f23b-fa66-4314-9aa9-adf19be7f51e", 1293 | "colab": { 1294 | "base_uri": "https://localhost:8080/" 1295 | } 1296 | }, 1297 | "source": [ 1298 | "print('Enter a list of past 7-days prices separated by space.')\n", 1299 | "\n", 1300 | "prices = [int(x) for x in input().split()]" 1301 | ], 1302 | "execution_count": 7, 1303 | "outputs": [ 1304 | { 1305 | "output_type": "stream", 1306 | "text": [ 1307 | "Enter a list of past 7-days prices separated by space.\n", 1308 | "3300 3333 3340 3350 3345\n" 1309 | ], 1310 | "name": "stdout" 1311 | } 1312 | ] 1313 | }, 1314 | { 1315 | "cell_type": "code", 1316 | "metadata": { 1317 | "id": "hxJn0mUQemEJ", 1318 | "outputId": "8da8e312-88ae-4786-c1e8-b7aa08d3ca58", 1319 | "colab": { 1320 | "base_uri": "https://localhost:8080/" 1321 | } 1322 | }, 1323 | "source": [ 1324 | "normalized_prices = [(i/prices[0]) for i in prices]\n", 1325 | "print(f'''Original prices = {prices}\n", 1326 | "Normalized prices = {normalized_prices}''')" 1327 | ], 1328 | "execution_count": 12, 1329 | "outputs": [ 1330 | { 1331 | "output_type": "stream", 1332 | "text": [ 1333 | "Original prices = [3300, 3333, 3340, 3350, 3345]\n", 1334 | "Normalized prices = [1.0, 1.01, 1.0121212121212122, 1.0151515151515151, 1.0136363636363637]\n" 1335 | ], 1336 | "name": "stdout" 1337 | } 1338 | ] 1339 | }, 1340 | { 1341 | "cell_type": "markdown", 1342 | "metadata": { 1343 | "id": "aXkGeaUza3d0" 1344 | }, 1345 | "source": [ 1346 | "# MINI CHALLENGE SOLUTION" 1347 | ] 1348 | }, 1349 | { 1350 | "cell_type": "markdown", 1351 | "metadata": { 1352 | "id": "Pc-Wifl4a_hA" 1353 | }, 1354 | "source": [ 1355 | "**MINI CHALLENGE #1:**\n", 1356 | "- **Write a code that takes in a string and prints it out on the screen except for any letter 'T'. You can replace the letter 'T' with '*'.**" 1357 | ] 1358 | }, 1359 | { 1360 | "cell_type": "code", 1361 | "metadata": { 1362 | "id": "ZVy77WA2a5QC" 1363 | }, 1364 | "source": [ 1365 | "for letter in 'TSLA':\n", 1366 | " if letter == 'T':\n", 1367 | " print('*')\n", 1368 | " else:\n", 1369 | " print(letter)" 1370 | ], 1371 | "execution_count": null, 1372 | "outputs": [] 1373 | }, 1374 | { 1375 | "cell_type": "markdown", 1376 | "metadata": { 1377 | "id": "9OSRnPn0bf-u" 1378 | }, 1379 | "source": [ 1380 | "**MINI CHALLENGE #2 SOLUTION:**\n", 1381 | "- **Write a code that takes in the maximum and minimum limits from the user and prints out even numbers only between the provided range**" 1382 | ] 1383 | }, 1384 | { 1385 | "cell_type": "code", 1386 | "metadata": { 1387 | "id": "jqQpkqe-bgaW" 1388 | }, 1389 | "source": [ 1390 | "min = int(input(\"Enter the price (lower bound: \"))\n", 1391 | "max = int(input(\"Enter the price (Upper bound: \"))\n", 1392 | "\n", 1393 | "for i in range(min, max):\n", 1394 | " if i%2 == 0: \n", 1395 | " print(i)" 1396 | ], 1397 | "execution_count": null, 1398 | "outputs": [] 1399 | }, 1400 | { 1401 | "cell_type": "markdown", 1402 | "metadata": { 1403 | "id": "L6-jK2s0bwXc" 1404 | }, 1405 | "source": [ 1406 | "**MINI CHALLENGE #3 SOLUTION:**\n", 1407 | "- **Write a code that generates the following table:**\n", 1408 | "```\n", 1409 | "1 1 1\n", 1410 | "2 4 8\n", 1411 | "3 9 27\n", 1412 | "4 16 64\n", 1413 | "5 25 125\n", 1414 | "6 36 216\n", 1415 | "7 49 343\n", 1416 | "8 64 512\n", 1417 | "9 81 729\n", 1418 | "10 100 1000\n", 1419 | "```\n" 1420 | ] 1421 | }, 1422 | { 1423 | "cell_type": "code", 1424 | "metadata": { 1425 | "id": "YU82QHJ9boi2" 1426 | }, 1427 | "source": [ 1428 | "for x in range(1, 11):\n", 1429 | " print('{} {} {}'.format(x, x*x, x*x*x))" 1430 | ], 1431 | "execution_count": null, 1432 | "outputs": [] 1433 | }, 1434 | { 1435 | "cell_type": "markdown", 1436 | "metadata": { 1437 | "id": "KfpFJ7tBb8RO" 1438 | }, 1439 | "source": [ 1440 | "**MINI CHALLENGE #4 SOLUTION:**\n", 1441 | "- **Write a code that displays numbers from 1 to 30 (including 30) using for and while loops**" 1442 | ] 1443 | }, 1444 | { 1445 | "cell_type": "code", 1446 | "metadata": { 1447 | "id": "UukURLDIb0go" 1448 | }, 1449 | "source": [ 1450 | "i = 1\n", 1451 | "while (i < 31):\n", 1452 | " print (i)\n", 1453 | " i = i+1" 1454 | ], 1455 | "execution_count": null, 1456 | "outputs": [] 1457 | }, 1458 | { 1459 | "cell_type": "code", 1460 | "metadata": { 1461 | "id": "iTYnoI4-cES_" 1462 | }, 1463 | "source": [ 1464 | "for i in range(1, 31):\n", 1465 | " print(i)" 1466 | ], 1467 | "execution_count": null, 1468 | "outputs": [] 1469 | }, 1470 | { 1471 | "cell_type": "markdown", 1472 | "metadata": { 1473 | "id": "YGwSp4VScYc6" 1474 | }, 1475 | "source": [ 1476 | "**MINI CHALLENGE #5 SOLUTION:**\n", 1477 | "- **Create a rolling dice game that assume we have two dice (#1 and #2). The dice is being thrown and a random number is generated everytime. The game should be designed such that it prompts the user to ask if he/she would like to keep playing or exit the game.**" 1478 | ] 1479 | }, 1480 | { 1481 | "cell_type": "code", 1482 | "metadata": { 1483 | "id": "bQizGjKvcRW7" 1484 | }, 1485 | "source": [ 1486 | "import random\n", 1487 | "\n", 1488 | "keep_rolling = \"y\"\n", 1489 | "\n", 1490 | "while keep_rolling == \"y\":\n", 1491 | " print(\"Rolling the dices, please wait!...\")\n", 1492 | " print(\"Rolling results for Dice #1:\", random.randint(1, 6))\n", 1493 | " print(\"Rolling results for Dice #2:\", random.randint(1, 6))\n", 1494 | "\n", 1495 | " keep_rolling = input(\"Do you want to roll again?\")" 1496 | ], 1497 | "execution_count": null, 1498 | "outputs": [] 1499 | }, 1500 | { 1501 | "cell_type": "markdown", 1502 | "metadata": { 1503 | "id": "fhPFAXMFdAgv" 1504 | }, 1505 | "source": [ 1506 | "**MINI CHALLENGE #6 SOLUTION:**\n", 1507 | "- **Write a code that continiously gets data from the user and calculates the average and print out on the screen. The code exits when the user enters 'e'.**" 1508 | ] 1509 | }, 1510 | { 1511 | "cell_type": "code", 1512 | "metadata": { 1513 | "id": "TwdLz4BOcesU" 1514 | }, 1515 | "source": [ 1516 | "print(\"Keep entering numbers and I will display the average to you!\")\n", 1517 | "avg = 0\n", 1518 | "n = 0\n", 1519 | "while True:\n", 1520 | " x = input(\"Enter a number: \")\n", 1521 | " \n", 1522 | " # Check if the user wants to exit (i.e.: break the loop)\n", 1523 | " if x == 'e':\n", 1524 | " break\n", 1525 | " \n", 1526 | " x = int(x)\n", 1527 | " n = n + 1\n", 1528 | " \n", 1529 | " avg = ((avg * (n - 1) ) + x) / n\n", 1530 | " print (\"The current average is \", avg)" 1531 | ], 1532 | "execution_count": null, 1533 | "outputs": [] 1534 | }, 1535 | { 1536 | "cell_type": "markdown", 1537 | "metadata": { 1538 | "id": "Ga5YJU8fhV1V" 1539 | }, 1540 | "source": [ 1541 | "**MINI CHALLENGE #7 SOLUTION:**\n", 1542 | "- **Write a code that takes in a number (range between 1 and 9) from the user and print out the multiplication table up until that number.**" 1543 | ] 1544 | }, 1545 | { 1546 | "cell_type": "code", 1547 | "metadata": { 1548 | "id": "XPRNPUmHddYx" 1549 | }, 1550 | "source": [ 1551 | "number = int(input(\"Enter a number between 1 and 9: \"))\n", 1552 | "\n", 1553 | "for x in range(1, number+1): # slow loop \n", 1554 | " for y in range(1, 11): # fast loop\n", 1555 | " print('{} x {} = {}'.format(x, y, x*y))" 1556 | ], 1557 | "execution_count": null, 1558 | "outputs": [] 1559 | }, 1560 | { 1561 | "cell_type": "markdown", 1562 | "metadata": { 1563 | "id": "6eUUTJKEhgzw" 1564 | }, 1565 | "source": [ 1566 | "**MINI CHALLENGE #8 SOLUTION:**\n", 1567 | "- **Write a code that takes in a list of prices of a stock for the past 7 days and then normalize the prices** " 1568 | ] 1569 | }, 1570 | { 1571 | "cell_type": "code", 1572 | "metadata": { 1573 | "id": "G-i-cSuRhiZF" 1574 | }, 1575 | "source": [ 1576 | "print('Enter a list of past 7-days prices separated by a space:')\n", 1577 | "prices = [int(x) for x in input().split()]" 1578 | ], 1579 | "execution_count": null, 1580 | "outputs": [] 1581 | }, 1582 | { 1583 | "cell_type": "code", 1584 | "metadata": { 1585 | "id": "05OwM9e2hsg7" 1586 | }, 1587 | "source": [ 1588 | "normalized_prices = [ (i/prices[0]) for i in prices]\n", 1589 | "print('Orginal Prices: {}\\nNormalized Prices: {}\\n'.format(prices, normalized_prices))" 1590 | ], 1591 | "execution_count": null, 1592 | "outputs": [] 1593 | }, 1594 | { 1595 | "cell_type": "code", 1596 | "metadata": { 1597 | "id": "Po4N2n9TSFvL" 1598 | }, 1599 | "source": [ 1600 | "" 1601 | ], 1602 | "execution_count": null, 1603 | "outputs": [] 1604 | } 1605 | ] 1606 | } -------------------------------------------------------------------------------- /5_Python_101_Functions_.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "5. Python 101 - Functions .ipynb", 7 | "provenance": [], 8 | "collapsed_sections": [], 9 | "include_colab_link": true 10 | }, 11 | "kernelspec": { 12 | "name": "python3", 13 | "display_name": "Python 3" 14 | } 15 | }, 16 | "cells": [ 17 | { 18 | "cell_type": "markdown", 19 | "metadata": { 20 | "id": "view-in-github", 21 | "colab_type": "text" 22 | }, 23 | "source": [ 24 | "\"Open" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": { 30 | "id": "2qdHbV6LKCdn" 31 | }, 32 | "source": [ 33 | "# 1. BUILT-IN FUNCTIONS" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "metadata": { 39 | "id": "e027nLRtKclL" 40 | }, 41 | "source": [ 42 | "# There are many built-in functions that you can leverage directly \n", 43 | "# Let's define 2 lists x and y\n", 44 | "\n", 45 | "x = [4, 5, 1, 2, 8, 5]\n", 46 | "y = list(range(1,7))" 47 | ], 48 | "execution_count": 5, 49 | "outputs": [] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "metadata": { 54 | "id": "B_q1ds-xKcnQ", 55 | "outputId": "fbd3cf71-fba8-4af7-b4c6-9a8519e81e78", 56 | "colab": { 57 | "base_uri": "https://localhost:8080/" 58 | } 59 | }, 60 | "source": [ 61 | "x" 62 | ], 63 | "execution_count": 6, 64 | "outputs": [ 65 | { 66 | "output_type": "execute_result", 67 | "data": { 68 | "text/plain": [ 69 | "[4, 5, 1, 2, 8, 5]" 70 | ] 71 | }, 72 | "metadata": { 73 | "tags": [] 74 | }, 75 | "execution_count": 6 76 | } 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "metadata": { 82 | "id": "wlYds_UIK3Uq", 83 | "outputId": "c8cbfb91-88ac-4265-e9a2-192e6b55b832", 84 | "colab": { 85 | "base_uri": "https://localhost:8080/" 86 | } 87 | }, 88 | "source": [ 89 | "y" 90 | ], 91 | "execution_count": 7, 92 | "outputs": [ 93 | { 94 | "output_type": "execute_result", 95 | "data": { 96 | "text/plain": [ 97 | "[1, 2, 3, 4, 5, 6]" 98 | ] 99 | }, 100 | "metadata": { 101 | "tags": [] 102 | }, 103 | "execution_count": 7 104 | } 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "metadata": { 110 | "id": "sOb6YyohK3XA", 111 | "outputId": "c023e07e-100f-445a-c854-a9f8c4ac7b53", 112 | "colab": { 113 | "base_uri": "https://localhost:8080/" 114 | } 115 | }, 116 | "source": [ 117 | "# Let's obtain the length of y\n", 118 | "\n", 119 | "len(y)" 120 | ], 121 | "execution_count": 8, 122 | "outputs": [ 123 | { 124 | "output_type": "execute_result", 125 | "data": { 126 | "text/plain": [ 127 | "6" 128 | ] 129 | }, 130 | "metadata": { 131 | "tags": [] 132 | }, 133 | "execution_count": 8 134 | } 135 | ] 136 | }, 137 | { 138 | "cell_type": "code", 139 | "metadata": { 140 | "id": "E2d-scjBK3f_", 141 | "outputId": "bc84deff-43e0-439e-8768-41bdd35e5a69", 142 | "colab": { 143 | "base_uri": "https://localhost:8080/" 144 | } 145 | }, 146 | "source": [ 147 | "# Let's obtain the minimum value \n", 148 | "\n", 149 | "min(x)" 150 | ], 151 | "execution_count": 9, 152 | "outputs": [ 153 | { 154 | "output_type": "execute_result", 155 | "data": { 156 | "text/plain": [ 157 | "1" 158 | ] 159 | }, 160 | "metadata": { 161 | "tags": [] 162 | }, 163 | "execution_count": 9 164 | } 165 | ] 166 | }, 167 | { 168 | "cell_type": "code", 169 | "metadata": { 170 | "id": "MPcUuoY6K3id", 171 | "outputId": "400b383e-e947-4a75-a9cb-d82e52377504", 172 | "colab": { 173 | "base_uri": "https://localhost:8080/" 174 | } 175 | }, 176 | "source": [ 177 | "# Let's obtain the maximum value\n", 178 | "\n", 179 | "max(x)" 180 | ], 181 | "execution_count": 10, 182 | "outputs": [ 183 | { 184 | "output_type": "execute_result", 185 | "data": { 186 | "text/plain": [ 187 | "8" 188 | ] 189 | }, 190 | "metadata": { 191 | "tags": [] 192 | }, 193 | "execution_count": 10 194 | } 195 | ] 196 | }, 197 | { 198 | "cell_type": "code", 199 | "metadata": { 200 | "id": "oo4EvfwgK3nQ" 201 | }, 202 | "source": [ 203 | "# Let's create a tuple out of the list\n", 204 | "\n", 205 | "z = tuple(x)" 206 | ], 207 | "execution_count": 11, 208 | "outputs": [] 209 | }, 210 | { 211 | "cell_type": "code", 212 | "metadata": { 213 | "id": "gbcSW9n5Lrf0", 214 | "outputId": "c4c057db-96be-4e45-edcb-3fd117f96280", 215 | "colab": { 216 | "base_uri": "https://localhost:8080/" 217 | } 218 | }, 219 | "source": [ 220 | "z" 221 | ], 222 | "execution_count": 12, 223 | "outputs": [ 224 | { 225 | "output_type": "execute_result", 226 | "data": { 227 | "text/plain": [ 228 | "(4, 5, 1, 2, 8, 5)" 229 | ] 230 | }, 231 | "metadata": { 232 | "tags": [] 233 | }, 234 | "execution_count": 12 235 | } 236 | ] 237 | }, 238 | { 239 | "cell_type": "code", 240 | "metadata": { 241 | "id": "S-BLWy_AK3lL", 242 | "outputId": "0f870d9e-33c1-4d72-b2e0-940e93f1e3cb", 243 | "colab": { 244 | "base_uri": "https://localhost:8080/" 245 | } 246 | }, 247 | "source": [ 248 | "type(z)" 249 | ], 250 | "execution_count": 13, 251 | "outputs": [ 252 | { 253 | "output_type": "execute_result", 254 | "data": { 255 | "text/plain": [ 256 | "tuple" 257 | ] 258 | }, 259 | "metadata": { 260 | "tags": [] 261 | }, 262 | "execution_count": 13 263 | } 264 | ] 265 | }, 266 | { 267 | "cell_type": "code", 268 | "metadata": { 269 | "id": "NYVetBn-Kcpk", 270 | "outputId": "87ba666e-fa4f-4bac-9c48-29f3dba1e0af", 271 | "colab": { 272 | "base_uri": "https://localhost:8080/" 273 | } 274 | }, 275 | "source": [ 276 | "# Let's obtain the sum of elements in x\n", 277 | "\n", 278 | "sum(x)" 279 | ], 280 | "execution_count": 14, 281 | "outputs": [ 282 | { 283 | "output_type": "execute_result", 284 | "data": { 285 | "text/plain": [ 286 | "25" 287 | ] 288 | }, 289 | "metadata": { 290 | "tags": [] 291 | }, 292 | "execution_count": 14 293 | } 294 | ] 295 | }, 296 | { 297 | "cell_type": "markdown", 298 | "metadata": { 299 | "id": "CvaYA-XocFOc" 300 | }, 301 | "source": [ 302 | "**MINI CHALLENGE #1:**\n", 303 | "- **Write a code that takes in 2 lists x = [-1 -4 -7] and y = [-3 7 4] and calculates the absolute sum of all its elements |x+y|**\n" 304 | ] 305 | }, 306 | { 307 | "cell_type": "code", 308 | "metadata": { 309 | "id": "DMYqI7CBekNI", 310 | "outputId": "4aaa104e-755a-4ae7-992c-528de461fe63", 311 | "colab": { 312 | "base_uri": "https://localhost:8080/" 313 | } 314 | }, 315 | "source": [ 316 | "x = [-1, -4, -7]\n", 317 | "y = [-3, 7, 4]\n", 318 | "\n", 319 | "\n", 320 | "z = abs(sum(x+y))\n", 321 | "z" 322 | ], 323 | "execution_count": 17, 324 | "outputs": [ 325 | { 326 | "output_type": "execute_result", 327 | "data": { 328 | "text/plain": [ 329 | "4" 330 | ] 331 | }, 332 | "metadata": { 333 | "tags": [] 334 | }, 335 | "execution_count": 17 336 | } 337 | ] 338 | }, 339 | { 340 | "cell_type": "markdown", 341 | "metadata": { 342 | "id": "AHrwK11xMArY" 343 | }, 344 | "source": [ 345 | "# 2. FUNCTIONS" 346 | ] 347 | }, 348 | { 349 | "cell_type": "code", 350 | "metadata": { 351 | "id": "LhhFvM60MGrX" 352 | }, 353 | "source": [ 354 | "# Let's define a function named \"my_function\" that does not receive any arguments\n", 355 | "# The function simply prints out content and does not return anything\n", 356 | "\n", 357 | "def my_function():\n", 358 | " print(\"Hello world!\")\n" 359 | ], 360 | "execution_count": 21, 361 | "outputs": [] 362 | }, 363 | { 364 | "cell_type": "code", 365 | "metadata": { 366 | "id": "-jJdkGlGMGwE", 367 | "outputId": "f07301fa-bae3-4b82-8acc-0be238c918c8", 368 | "colab": { 369 | "base_uri": "https://localhost:8080/" 370 | } 371 | }, 372 | "source": [ 373 | "# Function call\n", 374 | "\n", 375 | "my_function()" 376 | ], 377 | "execution_count": 22, 378 | "outputs": [ 379 | { 380 | "output_type": "stream", 381 | "text": [ 382 | "Hello world!\n" 383 | ], 384 | "name": "stdout" 385 | } 386 | ] 387 | }, 388 | { 389 | "cell_type": "code", 390 | "metadata": { 391 | "id": "OSVyOu91MGuW" 392 | }, 393 | "source": [ 394 | "# Define a function that takes in argument x and return the squared value \n", 395 | "\n", 396 | "def squared(x):\n", 397 | " return x**2\n" 398 | ], 399 | "execution_count": 24, 400 | "outputs": [] 401 | }, 402 | { 403 | "cell_type": "code", 404 | "metadata": { 405 | "id": "NVPrMz2_MPz1", 406 | "outputId": "d1b01f68-ea78-4c21-d2bf-e55580c04b60", 407 | "colab": { 408 | "base_uri": "https://localhost:8080/" 409 | } 410 | }, 411 | "source": [ 412 | "# Call the function\n", 413 | "\n", 414 | "squared(5)" 415 | ], 416 | "execution_count": 25, 417 | "outputs": [ 418 | { 419 | "output_type": "execute_result", 420 | "data": { 421 | "text/plain": [ 422 | "25" 423 | ] 424 | }, 425 | "metadata": { 426 | "tags": [] 427 | }, 428 | "execution_count": 25 429 | } 430 | ] 431 | }, 432 | { 433 | "cell_type": "code", 434 | "metadata": { 435 | "id": "6ET-hFiSMPxi", 436 | "outputId": "48a2b2cf-4301-4df9-a33e-e5861b53ca92", 437 | "colab": { 438 | "base_uri": "https://localhost:8080/" 439 | } 440 | }, 441 | "source": [ 442 | "# Define a function with default value \n", 443 | "\n", 444 | "def squared(x = 3):\n", 445 | " return x ** 2\n", 446 | "\n", 447 | "squared()\n" 448 | ], 449 | "execution_count": 27, 450 | "outputs": [ 451 | { 452 | "output_type": "execute_result", 453 | "data": { 454 | "text/plain": [ 455 | "9" 456 | ] 457 | }, 458 | "metadata": { 459 | "tags": [] 460 | }, 461 | "execution_count": 27 462 | } 463 | ] 464 | }, 465 | { 466 | "cell_type": "code", 467 | "metadata": { 468 | "id": "-tiaDshNM48J", 469 | "outputId": "5ba61737-1ad4-43c6-99b2-d501e2b18089", 470 | "colab": { 471 | "base_uri": "https://localhost:8080/" 472 | } 473 | }, 474 | "source": [ 475 | "# If you pass an argument to the function, it overwrites the default value \n", 476 | "\n", 477 | "squared(9)" 478 | ], 479 | "execution_count": 28, 480 | "outputs": [ 481 | { 482 | "output_type": "execute_result", 483 | "data": { 484 | "text/plain": [ 485 | "81" 486 | ] 487 | }, 488 | "metadata": { 489 | "tags": [] 490 | }, 491 | "execution_count": 28 492 | } 493 | ] 494 | }, 495 | { 496 | "cell_type": "markdown", 497 | "metadata": { 498 | "id": "DB1zlBEEfDlA" 499 | }, 500 | "source": [ 501 | "**MINI CHALLENGE #2:** \n", 502 | "- **Write a code that takes in two inputs (number of shares and prices) from the user and calculate the total account balance**" 503 | ] 504 | }, 505 | { 506 | "cell_type": "code", 507 | "metadata": { 508 | "id": "s7fbv5eApK97" 509 | }, 510 | "source": [ 511 | "\n", 512 | "def total(units, price):\n", 513 | " amount = units * price\n", 514 | " return amount\n", 515 | "\n" 516 | ], 517 | "execution_count": 29, 518 | "outputs": [] 519 | }, 520 | { 521 | "cell_type": "code", 522 | "metadata": { 523 | "id": "qOeh1TiHrBjZ", 524 | "outputId": "f3e61f8a-c2be-45a7-a643-f3a50edd7133", 525 | "colab": { 526 | "base_uri": "https://localhost:8080/" 527 | } 528 | }, 529 | "source": [ 530 | "number_of_shares = int(input('Enter the number of shares: '))\n", 531 | "price = int(input('Enter the price'))\n", 532 | "\n", 533 | "total(number_of_shares, price)" 534 | ], 535 | "execution_count": 30, 536 | "outputs": [ 537 | { 538 | "output_type": "stream", 539 | "text": [ 540 | "Enter the number of shares: 10\n", 541 | "Enter the price230\n" 542 | ], 543 | "name": "stdout" 544 | }, 545 | { 546 | "output_type": "execute_result", 547 | "data": { 548 | "text/plain": [ 549 | "2300" 550 | ] 551 | }, 552 | "metadata": { 553 | "tags": [] 554 | }, 555 | "execution_count": 30 556 | } 557 | ] 558 | }, 559 | { 560 | "cell_type": "markdown", 561 | "metadata": { 562 | "id": "lBj4QkQEpLkX" 563 | }, 564 | "source": [ 565 | "# 3. LAMBDA EXPRESSIONS " 566 | ] 567 | }, 568 | { 569 | "cell_type": "code", 570 | "metadata": { 571 | "id": "YtkjNLEypRTb" 572 | }, 573 | "source": [ 574 | "# Lambda function is used to create a function without a name \n", 575 | "# Lambda functions are mainly used with filter() and map() [they will be discussed later on]. \n", 576 | "# Lambda function can receive any number of arguments, but can only have one expression." 577 | ], 578 | "execution_count": null, 579 | "outputs": [] 580 | }, 581 | { 582 | "cell_type": "code", 583 | "metadata": { 584 | "id": "FV5-hEWdpRdd" 585 | }, 586 | "source": [ 587 | "# let's see how to create a basic function that squares the input\n", 588 | "\n", 589 | "def my_function(x):\n", 590 | " return x**2" 591 | ], 592 | "execution_count": 31, 593 | "outputs": [] 594 | }, 595 | { 596 | "cell_type": "code", 597 | "metadata": { 598 | "id": "cQZDrvwCpRa3", 599 | "outputId": "0aaa0425-265a-416f-abf2-5ed118c1dddb", 600 | "colab": { 601 | "base_uri": "https://localhost:8080/" 602 | } 603 | }, 604 | "source": [ 605 | "# Function call\n", 606 | "\n", 607 | "my_function(3)" 608 | ], 609 | "execution_count": 32, 610 | "outputs": [ 611 | { 612 | "output_type": "execute_result", 613 | "data": { 614 | "text/plain": [ 615 | "9" 616 | ] 617 | }, 618 | "metadata": { 619 | "tags": [] 620 | }, 621 | "execution_count": 32 622 | } 623 | ] 624 | }, 625 | { 626 | "cell_type": "code", 627 | "metadata": { 628 | "id": "r5u0-IOBpRZq" 629 | }, 630 | "source": [ 631 | "# We can do the same task using Lambda expression\n", 632 | "# Note that there is no function name\n", 633 | "\n", 634 | "y = lambda x: x**2\n" 635 | ], 636 | "execution_count": 33, 637 | "outputs": [] 638 | }, 639 | { 640 | "cell_type": "code", 641 | "metadata": { 642 | "id": "hLsuWg7apRW9", 643 | "outputId": "981668b5-a341-4956-a38b-9a3f5fc75012", 644 | "colab": { 645 | "base_uri": "https://localhost:8080/" 646 | } 647 | }, 648 | "source": [ 649 | "y(5)" 650 | ], 651 | "execution_count": 34, 652 | "outputs": [ 653 | { 654 | "output_type": "execute_result", 655 | "data": { 656 | "text/plain": [ 657 | "25" 658 | ] 659 | }, 660 | "metadata": { 661 | "tags": [] 662 | }, 663 | "execution_count": 34 664 | } 665 | ] 666 | }, 667 | { 668 | "cell_type": "code", 669 | "metadata": { 670 | "id": "OKcE7JHBuzTj" 671 | }, 672 | "source": [ 673 | "# Note that lambda expression can take in more than one argument \n", 674 | "# there is only one expression that could be performed\n", 675 | "\n", 676 | "def summation(x,y,z):\n", 677 | " return x+y+z" 678 | ], 679 | "execution_count": 35, 680 | "outputs": [] 681 | }, 682 | { 683 | "cell_type": "code", 684 | "metadata": { 685 | "id": "VyEdRTwXuzQ4", 686 | "outputId": "5d2dc87e-6aea-41c1-9085-fb3890c7cea3", 687 | "colab": { 688 | "base_uri": "https://localhost:8080/" 689 | } 690 | }, 691 | "source": [ 692 | "summation(1,2,3)" 693 | ], 694 | "execution_count": 36, 695 | "outputs": [ 696 | { 697 | "output_type": "execute_result", 698 | "data": { 699 | "text/plain": [ 700 | "6" 701 | ] 702 | }, 703 | "metadata": { 704 | "tags": [] 705 | }, 706 | "execution_count": 36 707 | } 708 | ] 709 | }, 710 | { 711 | "cell_type": "code", 712 | "metadata": { 713 | "id": "kAuNql-zuzPE" 714 | }, 715 | "source": [ 716 | "result = lambda x,y,z: x+y+z" 717 | ], 718 | "execution_count": 37, 719 | "outputs": [] 720 | }, 721 | { 722 | "cell_type": "code", 723 | "metadata": { 724 | "id": "8PfLE79Lvuvg", 725 | "outputId": "cff67df8-c5b6-44ea-cda7-304864d8fac8", 726 | "colab": { 727 | "base_uri": "https://localhost:8080/" 728 | } 729 | }, 730 | "source": [ 731 | "result(1,2,3)" 732 | ], 733 | "execution_count": 38, 734 | "outputs": [ 735 | { 736 | "output_type": "execute_result", 737 | "data": { 738 | "text/plain": [ 739 | "6" 740 | ] 741 | }, 742 | "metadata": { 743 | "tags": [] 744 | }, 745 | "execution_count": 38 746 | } 747 | ] 748 | }, 749 | { 750 | "cell_type": "markdown", 751 | "metadata": { 752 | "id": "KTRBKK97fQGG" 753 | }, 754 | "source": [ 755 | "**MINI CHALLENGE #3:**\n", 756 | "- **Repeat mini challenge #2 (Write a code that takes in two inputs from the user and calculates the total) using lambda expressions instead**" 757 | ] 758 | }, 759 | { 760 | "cell_type": "code", 761 | "metadata": { 762 | "id": "jz5bvTOmuHhG", 763 | "outputId": "c4eec14b-9c02-4929-de23-c006f722a557", 764 | "colab": { 765 | "base_uri": "https://localhost:8080/" 766 | } 767 | }, 768 | "source": [ 769 | "result = lambda units, price: units * price\n", 770 | "\n", 771 | "number_of_shares = int(input('Enter the number of shares: '))\n", 772 | "price = int(input('Enter the price'))\n", 773 | "\n", 774 | "result(number_of_shares, price)" 775 | ], 776 | "execution_count": 41, 777 | "outputs": [ 778 | { 779 | "output_type": "stream", 780 | "text": [ 781 | "Enter the number of shares: 34\n", 782 | "Enter the price200\n" 783 | ], 784 | "name": "stdout" 785 | }, 786 | { 787 | "output_type": "execute_result", 788 | "data": { 789 | "text/plain": [ 790 | "6800" 791 | ] 792 | }, 793 | "metadata": { 794 | "tags": [] 795 | }, 796 | "execution_count": 41 797 | } 798 | ] 799 | }, 800 | { 801 | "cell_type": "markdown", 802 | "metadata": { 803 | "id": "S8pekOcjKF6H" 804 | }, 805 | "source": [ 806 | "# 4. MAP " 807 | ] 808 | }, 809 | { 810 | "cell_type": "code", 811 | "metadata": { 812 | "id": "-zx6IFX7KdKi" 813 | }, 814 | "source": [ 815 | "# The map() function takes in a function and a list.\n", 816 | "# map() performs an operation on the entire list and return the results in a new list.\n", 817 | "# Define two lists a and b\n", 818 | "\n", 819 | "a = [1, 2, 3, 4, 5]\n", 820 | "b = [1, 7, 9, 13, 6]\n" 821 | ], 822 | "execution_count": 43, 823 | "outputs": [] 824 | }, 825 | { 826 | "cell_type": "code", 827 | "metadata": { 828 | "id": "l4AEJ33iih46" 829 | }, 830 | "source": [ 831 | "# Let's define a function that adds two elements together\n", 832 | "\n", 833 | "def summation(a, b):\n", 834 | " return a+b\n" 835 | ], 836 | "execution_count": 49, 837 | "outputs": [] 838 | }, 839 | { 840 | "cell_type": "code", 841 | "metadata": { 842 | "id": "8ZEm6BjIKdQ7", 843 | "outputId": "bab76958-c3da-4024-b177-9032269073be", 844 | "colab": { 845 | "base_uri": "https://localhost:8080/" 846 | } 847 | }, 848 | "source": [ 849 | "# You can now use map() to apply a function to the entire list and generate a new list\n", 850 | "\n", 851 | "c = list(map(summation, a, b))\n", 852 | "c" 853 | ], 854 | "execution_count": 50, 855 | "outputs": [ 856 | { 857 | "output_type": "execute_result", 858 | "data": { 859 | "text/plain": [ 860 | "[2, 9, 12, 17, 11]" 861 | ] 862 | }, 863 | "metadata": { 864 | "tags": [] 865 | }, 866 | "execution_count": 50 867 | } 868 | ] 869 | }, 870 | { 871 | "cell_type": "code", 872 | "metadata": { 873 | "id": "pc6LxQQFKdM2", 874 | "outputId": "df50babb-1001-4571-ebcd-dcc07029ae15", 875 | "colab": { 876 | "base_uri": "https://localhost:8080/" 877 | } 878 | }, 879 | "source": [ 880 | "# map could be used with Lambda as follows\n", 881 | "# lambda function is an anonymous function that take any number of arguments and can only have one expression\n", 882 | "\n", 883 | "input_list = [1, 2, 3, 4]\n", 884 | "\n", 885 | "out_list = list(map(lambda x: x ** 2, input_list))\n", 886 | "out_list" 887 | ], 888 | "execution_count": 52, 889 | "outputs": [ 890 | { 891 | "output_type": "execute_result", 892 | "data": { 893 | "text/plain": [ 894 | "[1, 4, 9, 16]" 895 | ] 896 | }, 897 | "metadata": { 898 | "tags": [] 899 | }, 900 | "execution_count": 52 901 | } 902 | ] 903 | }, 904 | { 905 | "cell_type": "markdown", 906 | "metadata": { 907 | "id": "Dj4Wcbr1gLo8" 908 | }, 909 | "source": [ 910 | "**MINI CHALLENGE #4:**\n", 911 | "- **Write a function that takes an argument and return its cubic value**\n", 912 | "- **Define a list of integers ranging from -10 to 10** \n", 913 | "- **Apply the function to the entire list and generate a new output list** \n" 914 | ] 915 | }, 916 | { 917 | "cell_type": "code", 918 | "metadata": { 919 | "id": "pqXiuFVxvU18", 920 | "outputId": "254fa6aa-e540-4bac-da91-1ecad6fd98ab", 921 | "colab": { 922 | "base_uri": "https://localhost:8080/" 923 | } 924 | }, 925 | "source": [ 926 | "def cubic(x):\n", 927 | " return x ** 3\n", 928 | "\n", 929 | "my_list = list(range(-10, 11))\n", 930 | "print(my_list)\n", 931 | "\n", 932 | "out_list = list(map(lambda x: cubic(x), my_list))\n", 933 | "print(out_list)" 934 | ], 935 | "execution_count": 59, 936 | "outputs": [ 937 | { 938 | "output_type": "stream", 939 | "text": [ 940 | "[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n", 941 | "[-1000, -729, -512, -343, -216, -125, -64, -27, -8, -1, 0, 1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]\n" 942 | ], 943 | "name": "stdout" 944 | } 945 | ] 946 | }, 947 | { 948 | "cell_type": "markdown", 949 | "metadata": { 950 | "id": "BtAxpyeGKGA1" 951 | }, 952 | "source": [ 953 | "# 5. FILTER\n" 954 | ] 955 | }, 956 | { 957 | "cell_type": "code", 958 | "metadata": { 959 | "id": "D5LVa00JKdz0", 960 | "outputId": "0b37afea-2ada-4a86-8aa2-8664c48eb14e", 961 | "colab": { 962 | "base_uri": "https://localhost:8080/" 963 | } 964 | }, 965 | "source": [ 966 | "# filter is used to create a list of elements for which a function returns \"True\".\n", 967 | "\n", 968 | "prices = [34, 36, 105, 598, 553, 225, 900]\n", 969 | "prices" 970 | ], 971 | "execution_count": 63, 972 | "outputs": [ 973 | { 974 | "output_type": "execute_result", 975 | "data": { 976 | "text/plain": [ 977 | "[34, 36, 105, 598, 553, 225, 900]" 978 | ] 979 | }, 980 | "metadata": { 981 | "tags": [] 982 | }, 983 | "execution_count": 63 984 | } 985 | ] 986 | }, 987 | { 988 | "cell_type": "code", 989 | "metadata": { 990 | "id": "cgQq4hlcKd4A", 991 | "outputId": "0859b5a8-9499-477d-c587-bfa12468ba82", 992 | "colab": { 993 | "base_uri": "https://localhost:8080/" 994 | } 995 | }, 996 | "source": [ 997 | "# return only even numbers\n", 998 | "\n", 999 | "out = list(filter( lambda x: (x % 2 == 0), prices))\n", 1000 | "out" 1001 | ], 1002 | "execution_count": 64, 1003 | "outputs": [ 1004 | { 1005 | "output_type": "execute_result", 1006 | "data": { 1007 | "text/plain": [ 1008 | "[34, 36, 598, 900]" 1009 | ] 1010 | }, 1011 | "metadata": { 1012 | "tags": [] 1013 | }, 1014 | "execution_count": 64 1015 | } 1016 | ] 1017 | }, 1018 | { 1019 | "cell_type": "code", 1020 | "metadata": { 1021 | "id": "shory4UpKd2Y", 1022 | "outputId": "a3a536ed-37f0-4d01-bf4e-ad22307d943e", 1023 | "colab": { 1024 | "base_uri": "https://localhost:8080/" 1025 | } 1026 | }, 1027 | "source": [ 1028 | "# Return prices that are greater than or equal 100\n", 1029 | "\n", 1030 | "out = list( filter( lambda x: (x >= 100), prices))\n", 1031 | "out" 1032 | ], 1033 | "execution_count": 65, 1034 | "outputs": [ 1035 | { 1036 | "output_type": "execute_result", 1037 | "data": { 1038 | "text/plain": [ 1039 | "[105, 598, 553, 225, 900]" 1040 | ] 1041 | }, 1042 | "metadata": { 1043 | "tags": [] 1044 | }, 1045 | "execution_count": 65 1046 | } 1047 | ] 1048 | }, 1049 | { 1050 | "cell_type": "code", 1051 | "metadata": { 1052 | "id": "uQi17-h_hlSf", 1053 | "outputId": "9f261f8d-ac73-4ddf-9c8d-7effcad6f63b", 1054 | "colab": { 1055 | "base_uri": "https://localhost:8080/" 1056 | } 1057 | }, 1058 | "source": [ 1059 | "# Return age between 200 and 250\n", 1060 | "\n", 1061 | "out = list( filter( lambda x: (x >= 200 and x<=250), prices))\n", 1062 | "out" 1063 | ], 1064 | "execution_count": 66, 1065 | "outputs": [ 1066 | { 1067 | "output_type": "execute_result", 1068 | "data": { 1069 | "text/plain": [ 1070 | "[225]" 1071 | ] 1072 | }, 1073 | "metadata": { 1074 | "tags": [] 1075 | }, 1076 | "execution_count": 66 1077 | } 1078 | ] 1079 | }, 1080 | { 1081 | "cell_type": "markdown", 1082 | "metadata": { 1083 | "id": "JZIiCmyvh7EW" 1084 | }, 1085 | "source": [ 1086 | "**MINI CHALLENGE #5:**\n", 1087 | "- **Write a code from the user that takes in a range (upper and lower bounds) and returns a list of positive and even numbers only** \n" 1088 | ] 1089 | }, 1090 | { 1091 | "cell_type": "code", 1092 | "metadata": { 1093 | "id": "4JDq7Y04ve0S", 1094 | "outputId": "43b2fdf7-1f07-4238-dae1-606d81a9c260", 1095 | "colab": { 1096 | "base_uri": "https://localhost:8080/" 1097 | } 1098 | }, 1099 | "source": [ 1100 | "min = int(input('Enter a number (lower bound) *must be negative* '))\n", 1101 | "max = int(input(\"Enter a number (upper bound) \"))\n", 1102 | "\n", 1103 | "my_list = range(min, max)\n", 1104 | "my_list\n", 1105 | "\n", 1106 | "even_grater_than_zero = list( filter( lambda x: (x>0 and x%2 == 0), my_list))\n", 1107 | "even_grater_than_zero" 1108 | ], 1109 | "execution_count": 69, 1110 | "outputs": [ 1111 | { 1112 | "output_type": "stream", 1113 | "text": [ 1114 | "Enter a number (lower bound) *must be negative* -12\n", 1115 | "Enter a number (upper bound) 6\n" 1116 | ], 1117 | "name": "stdout" 1118 | }, 1119 | { 1120 | "output_type": "execute_result", 1121 | "data": { 1122 | "text/plain": [ 1123 | "[2, 4]" 1124 | ] 1125 | }, 1126 | "metadata": { 1127 | "tags": [] 1128 | }, 1129 | "execution_count": 69 1130 | } 1131 | ] 1132 | }, 1133 | { 1134 | "cell_type": "markdown", 1135 | "metadata": { 1136 | "id": "BTLG7E2YeYIu" 1137 | }, 1138 | "source": [ 1139 | "# MINI CHALLENGE SOLUTIONS" 1140 | ] 1141 | }, 1142 | { 1143 | "cell_type": "markdown", 1144 | "metadata": { 1145 | "id": "Sr6wSsDGecLe" 1146 | }, 1147 | "source": [ 1148 | "**MINI CHALLENGE #1 SOLUTION:**\n", 1149 | "- **Write a code that takes in 2 lists x = [-1 -4 -7] and y = [-3 7 4] and calculates the absolute sum of all its elements |x+y|**" 1150 | ] 1151 | }, 1152 | { 1153 | "cell_type": "code", 1154 | "metadata": { 1155 | "id": "Ytdw0BKxKFRx", 1156 | "outputId": "60213af7-fbf9-4732-df56-c6263267ef27", 1157 | "colab": { 1158 | "base_uri": "https://localhost:8080/", 1159 | "height": 34 1160 | } 1161 | }, 1162 | "source": [ 1163 | "x = [-1, -4, -7]\n", 1164 | "y = [-3, 7, 4]\n", 1165 | "z = abs(sum(x+y))\n", 1166 | "z" 1167 | ], 1168 | "execution_count": null, 1169 | "outputs": [ 1170 | { 1171 | "output_type": "execute_result", 1172 | "data": { 1173 | "text/plain": [ 1174 | "4" 1175 | ] 1176 | }, 1177 | "metadata": { 1178 | "tags": [] 1179 | }, 1180 | "execution_count": 11 1181 | } 1182 | ] 1183 | }, 1184 | { 1185 | "cell_type": "markdown", 1186 | "metadata": { 1187 | "id": "YAh_RlMreu3V" 1188 | }, 1189 | "source": [ 1190 | "**MINI CHALLENGE #2: SOLUTION** \n", 1191 | "- **Write a code that takes in two inputs (number of units and prices) from the user and calculate the total account balance**" 1192 | ] 1193 | }, 1194 | { 1195 | "cell_type": "code", 1196 | "metadata": { 1197 | "id": "7zwqjcIresGA" 1198 | }, 1199 | "source": [ 1200 | "def total(units, price):\n", 1201 | " amount = units * price\n", 1202 | " return(amount)" 1203 | ], 1204 | "execution_count": null, 1205 | "outputs": [] 1206 | }, 1207 | { 1208 | "cell_type": "code", 1209 | "metadata": { 1210 | "id": "MjKWBisLet6b", 1211 | "outputId": "65db3176-bed8-4829-f208-559309835034", 1212 | "colab": { 1213 | "base_uri": "https://localhost:8080/", 1214 | "height": 67 1215 | } 1216 | }, 1217 | "source": [ 1218 | "num_shares = int(input(\"Enter the number of shares: \"))\n", 1219 | "price = int(input(\"Enter the price per share: \"))\n", 1220 | "account_balance = total(num_shares, price)\n", 1221 | "\n", 1222 | "print('Total account balance = {}'.format(account_balance))" 1223 | ], 1224 | "execution_count": null, 1225 | "outputs": [ 1226 | { 1227 | "output_type": "stream", 1228 | "text": [ 1229 | "Enter the number of shares: 80\n", 1230 | "Enter the price per share: 5\n", 1231 | "Total account balance = 400\n" 1232 | ], 1233 | "name": "stdout" 1234 | } 1235 | ] 1236 | }, 1237 | { 1238 | "cell_type": "markdown", 1239 | "metadata": { 1240 | "id": "fCXG1j3qfipT" 1241 | }, 1242 | "source": [ 1243 | "**MINI CHALLENGE #3 SOLUTION**\n", 1244 | "- **Repeat mini challenge #2 (Write a code that takes in two inputs from the user and calculates the total) using lambda expressions instead**" 1245 | ] 1246 | }, 1247 | { 1248 | "cell_type": "code", 1249 | "metadata": { 1250 | "id": "oYBrDfsTe-pI", 1251 | "outputId": "cf9c2c4b-4710-4c88-8171-bd14e57b55d9", 1252 | "colab": { 1253 | "base_uri": "https://localhost:8080/", 1254 | "height": 67 1255 | } 1256 | }, 1257 | "source": [ 1258 | "num_shares = int(input(\"Enter the number of shares: \"))\n", 1259 | "price = int(input(\"Enter the price per share: \"))\n", 1260 | "\n", 1261 | "account_balance = lambda num_shares, price : num_shares * price\n", 1262 | "print('Total = {}'.format(account_balance(num_shares, price)))\n" 1263 | ], 1264 | "execution_count": null, 1265 | "outputs": [ 1266 | { 1267 | "output_type": "stream", 1268 | "text": [ 1269 | "Enter the number of shares: 80\n", 1270 | "Enter the price per share: 5\n", 1271 | "Total = 400\n" 1272 | ], 1273 | "name": "stdout" 1274 | } 1275 | ] 1276 | }, 1277 | { 1278 | "cell_type": "markdown", 1279 | "metadata": { 1280 | "id": "sAkiC9hYhHgX" 1281 | }, 1282 | "source": [ 1283 | "**MINI CHALLENGE #4 SOLUTION:**\n", 1284 | "- **Write a function that takes an argument and return its cubic value**\n", 1285 | "- **Define a list of integers ranging from -10 to 10** \n", 1286 | "- **Apply the function to the entire list and generate a new output list** " 1287 | ] 1288 | }, 1289 | { 1290 | "cell_type": "code", 1291 | "metadata": { 1292 | "id": "hw2O6o4XhDLN" 1293 | }, 1294 | "source": [ 1295 | "def cubic(x):\n", 1296 | " return (x*x*x)\n", 1297 | "\n", 1298 | "numbers = range(-10, 11)\n", 1299 | "numbers_cubed = list(map(lambda x: cubic(x), numbers))\n", 1300 | "print(list(numbers))\n", 1301 | "print(numbers_cubed)" 1302 | ], 1303 | "execution_count": null, 1304 | "outputs": [] 1305 | }, 1306 | { 1307 | "cell_type": "markdown", 1308 | "metadata": { 1309 | "id": "WafFpX3zifYK" 1310 | }, 1311 | "source": [ 1312 | "**MINI CHALLENGE #5 SOLUTION:**\n", 1313 | "- **Write a code from the user that takes in a range (upper and lower bounds) and returns a list of positive and even numbers only** \n" 1314 | ] 1315 | }, 1316 | { 1317 | "cell_type": "code", 1318 | "metadata": { 1319 | "id": "jbTis2cBib1x" 1320 | }, 1321 | "source": [ 1322 | "min = int(input(\"Enter a number (lower bound) *must be negative* : \"))\n", 1323 | "max = int(input(\"Enter a number (Upper bound:) \"))\n", 1324 | "\n", 1325 | "numbers = range(min, max)\n", 1326 | "even_greater_than_zero = list(filter(lambda x: (x > 0 and x%2 == 0), numbers))\n", 1327 | "print(even_greater_than_zero)\n" 1328 | ], 1329 | "execution_count": null, 1330 | "outputs": [] 1331 | } 1332 | ] 1333 | } -------------------------------------------------------------------------------- /6_Python_101_Files.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "6. Python 101 - Files.ipynb", 7 | "provenance": [], 8 | "collapsed_sections": [], 9 | "include_colab_link": true 10 | }, 11 | "kernelspec": { 12 | "name": "python3", 13 | "display_name": "Python 3" 14 | } 15 | }, 16 | "cells": [ 17 | { 18 | "cell_type": "markdown", 19 | "metadata": { 20 | "id": "view-in-github", 21 | "colab_type": "text" 22 | }, 23 | "source": [ 24 | "\"Open" 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "metadata": { 30 | "id": "iLfi8gKMoAd6" 31 | }, 32 | "source": [ 33 | "# 1. TEXT FILES" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "metadata": { 39 | "id": "7350Sd6-wjNI", 40 | "outputId": "0f91bb84-e016-4401-d158-18c9f529ad79", 41 | "colab": { 42 | "base_uri": "https://localhost:8080/" 43 | } 44 | }, 45 | "source": [ 46 | "from google.colab import drive\n", 47 | "drive.mount('/content/drive')" 48 | ], 49 | "execution_count": 3, 50 | "outputs": [ 51 | { 52 | "output_type": "stream", 53 | "text": [ 54 | "Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n" 55 | ], 56 | "name": "stdout" 57 | } 58 | ] 59 | }, 60 | { 61 | "cell_type": "markdown", 62 | "metadata": { 63 | "id": "r2IjrNQmoFxC" 64 | }, 65 | "source": [ 66 | "- open() is the key function to handle files \n", 67 | "- open() function takes two parameters: (1) filename (2) mode.\n", 68 | "- Modes for files opening: \n", 69 | "\n", 70 | " - \"r\" - Read - Default value. Opens a file for reading, error if the file does not exist\n", 71 | " - \"a\" - Append - Opens a file for appending, creates the file if it does not exist\n", 72 | " - \"w\" - Write - Opens a file for writing, creates the file if it does not exist\n", 73 | " - \"x\" - Create - Creates the specified file, returns an error if the file exists\n", 74 | "\n", 75 | "- files can be used in a binary or text mode\n", 76 | "\n", 77 | " - \"t\" - Text - Default value. Text mode\n", 78 | " - \"b\" - Binary - Binary mode (e.g. images)" 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "metadata": { 84 | "id": "xEbqa95ArXlE", 85 | "outputId": "41e962da-272b-4e1e-9314-181c3ed34fed", 86 | "colab": { 87 | "base_uri": "https://localhost:8080/" 88 | } 89 | }, 90 | "source": [ 91 | "# In order to access data on Google Drive, you need to mount the drive to access it's content\n", 92 | "\n", 93 | "from google.colab import drive\n", 94 | "drive.mount('/content/drive')\n" 95 | ], 96 | "execution_count": 4, 97 | "outputs": [ 98 | { 99 | "output_type": "stream", 100 | "text": [ 101 | "Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n" 102 | ], 103 | "name": "stdout" 104 | } 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "metadata": { 110 | "id": "zqk6rO37oC_g", 111 | "outputId": "cadb6337-10be-4e46-8869-197db2e53426", 112 | "colab": { 113 | "base_uri": "https://localhost:8080/" 114 | } 115 | }, 116 | "source": [ 117 | "# Open and read text file\n", 118 | "\n", 119 | "f = open('/content/drive/My Drive/Python+for+Financial+Analysis+-+Course+Package/Part 1. Python Programming Fundamentals/sample_text_file.txt','r')\n", 120 | "print(f.read())\n" 121 | ], 122 | "execution_count": 5, 123 | "outputs": [ 124 | { 125 | "output_type": "stream", 126 | "text": [ 127 | "I am learning python now!\n", 128 | "It is super fun to learn Python programming \n", 129 | "I am learning how to handle files in python!This is a new line that I added to the file!\n" 130 | ], 131 | "name": "stdout" 132 | } 133 | ] 134 | }, 135 | { 136 | "cell_type": "code", 137 | "metadata": { 138 | "id": "m1596TUCoInJ", 139 | "outputId": "247861a6-debc-4357-fdff-8003a81c46ee", 140 | "colab": { 141 | "base_uri": "https://localhost:8080/" 142 | } 143 | }, 144 | "source": [ 145 | "# readline will be used to read the first line\n", 146 | "\n", 147 | "f = open('/content/drive/My Drive/Python+for+Financial+Analysis+-+Course+Package/Part 1. Python Programming Fundamentals/sample_text_file.txt','r')\n", 148 | "print(f.readline())\n" 149 | ], 150 | "execution_count": 6, 151 | "outputs": [ 152 | { 153 | "output_type": "stream", 154 | "text": [ 155 | "I am learning python now!\n", 156 | "\n" 157 | ], 158 | "name": "stdout" 159 | } 160 | ] 161 | }, 162 | { 163 | "cell_type": "code", 164 | "metadata": { 165 | "id": "-2Y52n0UoIpX", 166 | "outputId": "e763c379-14e6-4664-a0aa-530df499f14f", 167 | "colab": { 168 | "base_uri": "https://localhost:8080/" 169 | } 170 | }, 171 | "source": [ 172 | "# You can open the file and append content to it\n", 173 | "\n", 174 | "f = open('/content/drive/My Drive/Python+for+Financial+Analysis+-+Course+Package/Part 1. Python Programming Fundamentals/sample_text_file.txt','a')\n", 175 | "f.write('This is a new line that I added to the file!')\n" 176 | ], 177 | "execution_count": 7, 178 | "outputs": [ 179 | { 180 | "output_type": "execute_result", 181 | "data": { 182 | "text/plain": [ 183 | "44" 184 | ] 185 | }, 186 | "metadata": { 187 | "tags": [] 188 | }, 189 | "execution_count": 7 190 | } 191 | ] 192 | }, 193 | { 194 | "cell_type": "code", 195 | "metadata": { 196 | "id": "6twyC3vfoIrU" 197 | }, 198 | "source": [ 199 | "# close the file and let's check its content\n", 200 | "\n", 201 | "f.close()" 202 | ], 203 | "execution_count": 8, 204 | "outputs": [] 205 | }, 206 | { 207 | "cell_type": "code", 208 | "metadata": { 209 | "id": "sEQ6zDLaoOga" 210 | }, 211 | "source": [ 212 | "# Let's open the updated file after writing new content to it\n", 213 | "\n", 214 | "with open('/content/drive/My Drive/Python+for+Financial+Analysis+-+Course+Package/Part 1. Python Programming Fundamentals/sample_text_file.txt','r') as f:\n", 215 | " text_data = f.readlines()\n" 216 | ], 217 | "execution_count": 9, 218 | "outputs": [] 219 | }, 220 | { 221 | "cell_type": "code", 222 | "metadata": { 223 | "id": "HqnHR33noOiZ", 224 | "outputId": "133f40d2-5176-4e06-ad3f-3d94b82a6b49", 225 | "colab": { 226 | "base_uri": "https://localhost:8080/" 227 | } 228 | }, 229 | "source": [ 230 | "text_data" 231 | ], 232 | "execution_count": 10, 233 | "outputs": [ 234 | { 235 | "output_type": "execute_result", 236 | "data": { 237 | "text/plain": [ 238 | "['I am learning python now!\\n',\n", 239 | " 'It is super fun to learn Python programming \\n',\n", 240 | " 'I am learning how to handle files in python!This is a new line that I added to the file!This is a new line that I added to the file!']" 241 | ] 242 | }, 243 | "metadata": { 244 | "tags": [] 245 | }, 246 | "execution_count": 10 247 | } 248 | ] 249 | }, 250 | { 251 | "cell_type": "code", 252 | "metadata": { 253 | "id": "GJAfep33oOke", 254 | "outputId": "fb75de7c-74c3-4f0c-9ed6-ed77203523f6", 255 | "colab": { 256 | "base_uri": "https://localhost:8080/" 257 | } 258 | }, 259 | "source": [ 260 | "# split into a list of words\n", 261 | "\n", 262 | "for line in text_data:\n", 263 | " words = line.split()\n", 264 | " print(words)\n" 265 | ], 266 | "execution_count": 11, 267 | "outputs": [ 268 | { 269 | "output_type": "stream", 270 | "text": [ 271 | "['I', 'am', 'learning', 'python', 'now!']\n", 272 | "['It', 'is', 'super', 'fun', 'to', 'learn', 'Python', 'programming']\n", 273 | "['I', 'am', 'learning', 'how', 'to', 'handle', 'files', 'in', 'python!This', 'is', 'a', 'new', 'line', 'that', 'I', 'added', 'to', 'the', 'file!This', 'is', 'a', 'new', 'line', 'that', 'I', 'added', 'to', 'the', 'file!']\n" 274 | ], 275 | "name": "stdout" 276 | } 277 | ] 278 | }, 279 | { 280 | "cell_type": "markdown", 281 | "metadata": { 282 | "id": "_9ihcna1v0Y9" 283 | }, 284 | "source": [ 285 | "**MINI CHALLENGE #1:**\n", 286 | "- **Read the file 'fruits_input.txt'**\n", 287 | "- **compare the text file content to the list my_fruits = [\"Apple\", \"Pepper\", \"Orange\", \"Watermelon\", \"Tomatoes\"]**\n" 288 | ] 289 | }, 290 | { 291 | "cell_type": "code", 292 | "metadata": { 293 | "id": "FwqzbVBhx5Se" 294 | }, 295 | "source": [ 296 | "my_fruits = [\"Apple\", \"Pepper\", \"Orange\", \"Watermelon\", \"Tomatoes\"]\n", 297 | "\n", 298 | "with open('/content/drive/My Drive/Python+for+Financial+Analysis+-+Course+Package/Part 1. Python Programming Fundamentals/fruits_input.txt', 'r') as file:\n", 299 | " all_fruits = file.readlines()\n", 300 | " " 301 | ], 302 | "execution_count": 12, 303 | "outputs": [] 304 | }, 305 | { 306 | "cell_type": "code", 307 | "metadata": { 308 | "id": "iL0yRBfyMD6F", 309 | "outputId": "cca7adf6-9432-4655-e6c6-6d0bd6ae0dad", 310 | "colab": { 311 | "base_uri": "https://localhost:8080/" 312 | } 313 | }, 314 | "source": [ 315 | "all_fruits" 316 | ], 317 | "execution_count": 13, 318 | "outputs": [ 319 | { 320 | "output_type": "execute_result", 321 | "data": { 322 | "text/plain": [ 323 | "['Acai\\n',\n", 324 | " 'Apple\\n',\n", 325 | " 'Akee\\n',\n", 326 | " 'Apricot\\n',\n", 327 | " 'Avocado\\n',\n", 328 | " 'Banana\\n',\n", 329 | " 'Bilberry\\n',\n", 330 | " 'Blackberry\\n',\n", 331 | " 'Blackcurrant\\n',\n", 332 | " 'Black sapote\\n',\n", 333 | " 'Blueberry\\n',\n", 334 | " 'Boysenberry\\n',\n", 335 | " \"Buddha's hand (fingered citron)\\n\",\n", 336 | " 'Crab apples\\n',\n", 337 | " 'Currant\\n',\n", 338 | " 'Cherry\\n',\n", 339 | " 'Cherimoya (Custard Apple)\\n',\n", 340 | " 'Chico fruit\\n',\n", 341 | " 'Cloudberry\\n',\n", 342 | " 'Coconut\\n',\n", 343 | " 'Cranberry\\n',\n", 344 | " 'Cucumber\\n',\n", 345 | " 'Damson\\n',\n", 346 | " 'Date\\n',\n", 347 | " 'Dragonfruit (or Pitaya)\\n',\n", 348 | " 'Durian\\n',\n", 349 | " 'Elderberry\\n',\n", 350 | " 'Feijoa\\n',\n", 351 | " 'Fig\\n',\n", 352 | " 'Goji berry\\n',\n", 353 | " 'Gooseberry\\n',\n", 354 | " 'Grape\\n',\n", 355 | " 'Raisin\\n',\n", 356 | " 'Grapefruit\\n',\n", 357 | " 'Guava\\n',\n", 358 | " 'Honeyberry\\n',\n", 359 | " 'Huckleberry\\n',\n", 360 | " 'Jabuticaba\\n',\n", 361 | " 'Jackfruit\\n',\n", 362 | " 'Jambul\\n',\n", 363 | " 'Japanese plum\\n',\n", 364 | " 'Jostaberry\\n',\n", 365 | " 'Jujube\\n',\n", 366 | " 'Juniper berry\\n',\n", 367 | " 'Kiwano (horned melon)\\n',\n", 368 | " 'Kiwifruit\\n',\n", 369 | " 'Kumquat\\n',\n", 370 | " 'Lemon\\n',\n", 371 | " 'Lime\\n',\n", 372 | " 'Loquat\\n',\n", 373 | " 'Longan\\n',\n", 374 | " 'Lychee\\n',\n", 375 | " 'Mango\\n',\n", 376 | " 'Mangosteen\\n',\n", 377 | " 'Marionberry\\n',\n", 378 | " 'Melon\\n',\n", 379 | " 'Cantaloupe\\n',\n", 380 | " 'Honeydew\\n',\n", 381 | " 'Watermelon\\n',\n", 382 | " 'Miracle fruit\\n',\n", 383 | " 'Mulberry\\n',\n", 384 | " 'Nectarine\\n',\n", 385 | " 'Nance\\n',\n", 386 | " 'Olive\\n',\n", 387 | " 'Orange\\n',\n", 388 | " 'Blood orange\\n',\n", 389 | " 'Clementine\\n',\n", 390 | " 'Mandarine\\n',\n", 391 | " 'Tangerine\\n',\n", 392 | " 'Papaya\\n',\n", 393 | " 'Passionfruit\\n',\n", 394 | " 'Peach\\n',\n", 395 | " 'Pear\\n',\n", 396 | " 'Persimmon\\n',\n", 397 | " 'Plantain\\n',\n", 398 | " 'Plum\\n',\n", 399 | " 'Prune (dried plum)\\n',\n", 400 | " 'Pineapple\\n',\n", 401 | " 'Pineberry\\n',\n", 402 | " 'Plumcot (or Pluot)\\n',\n", 403 | " 'Pomegranate\\n',\n", 404 | " 'Pomelo\\n',\n", 405 | " 'Purple mangosteen\\n',\n", 406 | " 'Quince\\n',\n", 407 | " 'Raspberry\\n',\n", 408 | " 'Salmonberry\\n',\n", 409 | " 'Rambutan (or Mamin Chino)\\n',\n", 410 | " 'Redcurrant\\n',\n", 411 | " 'Salal berry\\n',\n", 412 | " 'Salak\\n',\n", 413 | " 'Satsuma\\n',\n", 414 | " 'Soursop\\n',\n", 415 | " 'Star apple\\n',\n", 416 | " 'Star fruit\\n',\n", 417 | " 'Strawberry\\n',\n", 418 | " 'Surinam cherry\\n',\n", 419 | " 'Tamarillo\\n',\n", 420 | " 'Tamarind\\n',\n", 421 | " 'Ugli fruit\\n',\n", 422 | " 'White currant\\n',\n", 423 | " 'White sapote\\n',\n", 424 | " 'Yuzu\\n',\n", 425 | " '\\n']" 426 | ] 427 | }, 428 | "metadata": { 429 | "tags": [] 430 | }, 431 | "execution_count": 13 432 | } 433 | ] 434 | }, 435 | { 436 | "cell_type": "code", 437 | "metadata": { 438 | "id": "ZMZDbtbGMD8k", 439 | "outputId": "810454f6-6dcb-4640-cc26-37e7f5294545", 440 | "colab": { 441 | "base_uri": "https://localhost:8080/" 442 | } 443 | }, 444 | "source": [ 445 | "all_fruits = [ char.rstrip('\\n') for char in all_fruits]\n", 446 | "all_fruits" 447 | ], 448 | "execution_count": 14, 449 | "outputs": [ 450 | { 451 | "output_type": "execute_result", 452 | "data": { 453 | "text/plain": [ 454 | "['Acai',\n", 455 | " 'Apple',\n", 456 | " 'Akee',\n", 457 | " 'Apricot',\n", 458 | " 'Avocado',\n", 459 | " 'Banana',\n", 460 | " 'Bilberry',\n", 461 | " 'Blackberry',\n", 462 | " 'Blackcurrant',\n", 463 | " 'Black sapote',\n", 464 | " 'Blueberry',\n", 465 | " 'Boysenberry',\n", 466 | " \"Buddha's hand (fingered citron)\",\n", 467 | " 'Crab apples',\n", 468 | " 'Currant',\n", 469 | " 'Cherry',\n", 470 | " 'Cherimoya (Custard Apple)',\n", 471 | " 'Chico fruit',\n", 472 | " 'Cloudberry',\n", 473 | " 'Coconut',\n", 474 | " 'Cranberry',\n", 475 | " 'Cucumber',\n", 476 | " 'Damson',\n", 477 | " 'Date',\n", 478 | " 'Dragonfruit (or Pitaya)',\n", 479 | " 'Durian',\n", 480 | " 'Elderberry',\n", 481 | " 'Feijoa',\n", 482 | " 'Fig',\n", 483 | " 'Goji berry',\n", 484 | " 'Gooseberry',\n", 485 | " 'Grape',\n", 486 | " 'Raisin',\n", 487 | " 'Grapefruit',\n", 488 | " 'Guava',\n", 489 | " 'Honeyberry',\n", 490 | " 'Huckleberry',\n", 491 | " 'Jabuticaba',\n", 492 | " 'Jackfruit',\n", 493 | " 'Jambul',\n", 494 | " 'Japanese plum',\n", 495 | " 'Jostaberry',\n", 496 | " 'Jujube',\n", 497 | " 'Juniper berry',\n", 498 | " 'Kiwano (horned melon)',\n", 499 | " 'Kiwifruit',\n", 500 | " 'Kumquat',\n", 501 | " 'Lemon',\n", 502 | " 'Lime',\n", 503 | " 'Loquat',\n", 504 | " 'Longan',\n", 505 | " 'Lychee',\n", 506 | " 'Mango',\n", 507 | " 'Mangosteen',\n", 508 | " 'Marionberry',\n", 509 | " 'Melon',\n", 510 | " 'Cantaloupe',\n", 511 | " 'Honeydew',\n", 512 | " 'Watermelon',\n", 513 | " 'Miracle fruit',\n", 514 | " 'Mulberry',\n", 515 | " 'Nectarine',\n", 516 | " 'Nance',\n", 517 | " 'Olive',\n", 518 | " 'Orange',\n", 519 | " 'Blood orange',\n", 520 | " 'Clementine',\n", 521 | " 'Mandarine',\n", 522 | " 'Tangerine',\n", 523 | " 'Papaya',\n", 524 | " 'Passionfruit',\n", 525 | " 'Peach',\n", 526 | " 'Pear',\n", 527 | " 'Persimmon',\n", 528 | " 'Plantain',\n", 529 | " 'Plum',\n", 530 | " 'Prune (dried plum)',\n", 531 | " 'Pineapple',\n", 532 | " 'Pineberry',\n", 533 | " 'Plumcot (or Pluot)',\n", 534 | " 'Pomegranate',\n", 535 | " 'Pomelo',\n", 536 | " 'Purple mangosteen',\n", 537 | " 'Quince',\n", 538 | " 'Raspberry',\n", 539 | " 'Salmonberry',\n", 540 | " 'Rambutan (or Mamin Chino)',\n", 541 | " 'Redcurrant',\n", 542 | " 'Salal berry',\n", 543 | " 'Salak',\n", 544 | " 'Satsuma',\n", 545 | " 'Soursop',\n", 546 | " 'Star apple',\n", 547 | " 'Star fruit',\n", 548 | " 'Strawberry',\n", 549 | " 'Surinam cherry',\n", 550 | " 'Tamarillo',\n", 551 | " 'Tamarind',\n", 552 | " 'Ugli fruit',\n", 553 | " 'White currant',\n", 554 | " 'White sapote',\n", 555 | " 'Yuzu',\n", 556 | " '']" 557 | ] 558 | }, 559 | "metadata": { 560 | "tags": [] 561 | }, 562 | "execution_count": 14 563 | } 564 | ] 565 | }, 566 | { 567 | "cell_type": "code", 568 | "metadata": { 569 | "id": "GSIATnQxMyFR", 570 | "outputId": "5c3581d6-228b-4945-b513-14f7087a4e5b", 571 | "colab": { 572 | "base_uri": "https://localhost:8080/" 573 | } 574 | }, 575 | "source": [ 576 | "selected_fruits = [ i for i in all_fruits if i in my_fruits]\n", 577 | "selected_fruits" 578 | ], 579 | "execution_count": 15, 580 | "outputs": [ 581 | { 582 | "output_type": "execute_result", 583 | "data": { 584 | "text/plain": [ 585 | "['Apple', 'Watermelon', 'Orange']" 586 | ] 587 | }, 588 | "metadata": { 589 | "tags": [] 590 | }, 591 | "execution_count": 15 592 | } 593 | ] 594 | }, 595 | { 596 | "cell_type": "markdown", 597 | "metadata": { 598 | "id": "mVEBiOmtnCp4" 599 | }, 600 | "source": [ 601 | "# 2. CSV FILES" 602 | ] 603 | }, 604 | { 605 | "cell_type": "code", 606 | "metadata": { 607 | "id": "C6-0bqrqmZS-" 608 | }, 609 | "source": [ 610 | "# you can read csv files using \"csv.reader\"\n", 611 | "import csv\n", 612 | "\n", 613 | "with open('/content/drive/My Drive/Python+for+Financial+Analysis+-+Course+Package/Part 1. Python Programming Fundamentals/sample_csv_file.csv') as f:\n", 614 | " readCSV = csv.reader(f, delimiter = ',')\n", 615 | " data = list(readCSV)\n" 616 | ], 617 | "execution_count": 17, 618 | "outputs": [] 619 | }, 620 | { 621 | "cell_type": "code", 622 | "metadata": { 623 | "id": "JlyWKV6fmng9", 624 | "outputId": "f226f88d-533e-429a-b1e9-8f933bf7ef59", 625 | "colab": { 626 | "base_uri": "https://localhost:8080/" 627 | } 628 | }, 629 | "source": [ 630 | "# Let's view the data\n", 631 | "\n", 632 | "data" 633 | ], 634 | "execution_count": 18, 635 | "outputs": [ 636 | { 637 | "output_type": "execute_result", 638 | "data": { 639 | "text/plain": [ 640 | "[['first', ' last', ' email', ' postal', ' gender', ' dollar'],\n", 641 | " ['Joseph', 'Patton', 'daafeja@boh.jm', 'M6U 5U7', 'Male', '$2,629.13 '],\n", 642 | " ['Noah', 'Moran', 'guutodi@bigwoc.kw', 'K2D 4M9', 'Male', '$8,626.96 '],\n", 643 | " ['Nina', 'Keller', 'azikez@gahew.mr', 'S1T 4E6', 'Male', '$9,072.02 ']]" 644 | ] 645 | }, 646 | "metadata": { 647 | "tags": [] 648 | }, 649 | "execution_count": 18 650 | } 651 | ] 652 | }, 653 | { 654 | "cell_type": "code", 655 | "metadata": { 656 | "id": "SuYdDHQpnZxL", 657 | "outputId": "108f1e4c-dddc-4cac-afed-69a799cf49c6", 658 | "colab": { 659 | "base_uri": "https://localhost:8080/" 660 | } 661 | }, 662 | "source": [ 663 | "# Let's view the first row\n", 664 | "\n", 665 | "data[0]" 666 | ], 667 | "execution_count": 19, 668 | "outputs": [ 669 | { 670 | "output_type": "execute_result", 671 | "data": { 672 | "text/plain": [ 673 | "['first', ' last', ' email', ' postal', ' gender', ' dollar']" 674 | ] 675 | }, 676 | "metadata": { 677 | "tags": [] 678 | }, 679 | "execution_count": 19 680 | } 681 | ] 682 | }, 683 | { 684 | "cell_type": "code", 685 | "metadata": { 686 | "id": "iPiq2lkMnbjW", 687 | "outputId": "10793376-427c-48c0-f0d9-624580a10324", 688 | "colab": { 689 | "base_uri": "https://localhost:8080/" 690 | } 691 | }, 692 | "source": [ 693 | "# Let's view the second row\n", 694 | "\n", 695 | "data[1]" 696 | ], 697 | "execution_count": 20, 698 | "outputs": [ 699 | { 700 | "output_type": "execute_result", 701 | "data": { 702 | "text/plain": [ 703 | "['Joseph', 'Patton', 'daafeja@boh.jm', 'M6U 5U7', 'Male', '$2,629.13 ']" 704 | ] 705 | }, 706 | "metadata": { 707 | "tags": [] 708 | }, 709 | "execution_count": 20 710 | } 711 | ] 712 | }, 713 | { 714 | "cell_type": "code", 715 | "metadata": { 716 | "id": "1EbBeptqm1XY" 717 | }, 718 | "source": [ 719 | "# Combine first and last names together to generate full_name\n", 720 | "\n", 721 | "full_name = []\n", 722 | "\n", 723 | "for row in data[1:4]:\n", 724 | " full_name.append(row[0]+ \" \"+row[1])\n", 725 | "\n", 726 | "\n" 727 | ], 728 | "execution_count": 23, 729 | "outputs": [] 730 | }, 731 | { 732 | "cell_type": "code", 733 | "metadata": { 734 | "id": "gD3H86PLm3FO", 735 | "outputId": "ac9d07ed-a5f8-416a-98ec-634ad5e87af5", 736 | "colab": { 737 | "base_uri": "https://localhost:8080/" 738 | } 739 | }, 740 | "source": [ 741 | "full_name" 742 | ], 743 | "execution_count": 24, 744 | "outputs": [ 745 | { 746 | "output_type": "execute_result", 747 | "data": { 748 | "text/plain": [ 749 | "['Joseph Patton', 'Noah Moran', 'Nina Keller']" 750 | ] 751 | }, 752 | "metadata": { 753 | "tags": [] 754 | }, 755 | "execution_count": 24 756 | } 757 | ] 758 | }, 759 | { 760 | "cell_type": "code", 761 | "metadata": { 762 | "id": "cjLRTZfcm5_I" 763 | }, 764 | "source": [ 765 | "dollar = []\n", 766 | "\n", 767 | "for row in data[1:4]:\n", 768 | " dollar.append(row[5])" 769 | ], 770 | "execution_count": 25, 771 | "outputs": [] 772 | }, 773 | { 774 | "cell_type": "code", 775 | "metadata": { 776 | "id": "wTXefzJAm6Wv", 777 | "outputId": "ecf1045e-b724-4b5b-a20b-a4e37c72dddc", 778 | "colab": { 779 | "base_uri": "https://localhost:8080/" 780 | } 781 | }, 782 | "source": [ 783 | "dollar" 784 | ], 785 | "execution_count": 26, 786 | "outputs": [ 787 | { 788 | "output_type": "execute_result", 789 | "data": { 790 | "text/plain": [ 791 | "['$2,629.13 ', '$8,626.96 ', '$9,072.02 ']" 792 | ] 793 | }, 794 | "metadata": { 795 | "tags": [] 796 | }, 797 | "execution_count": 26 798 | } 799 | ] 800 | }, 801 | { 802 | "cell_type": "markdown", 803 | "metadata": { 804 | "id": "fxYxNeqJxEmR" 805 | }, 806 | "source": [ 807 | "**MINI CHALLENGE #2:**\n", 808 | "- **Read the CSV file entitled \"S&P500_Stock_data.csv\" and print out the heading**\n", 809 | "- **Print out the first 5 rows of data**\n" 810 | ] 811 | }, 812 | { 813 | "cell_type": "code", 814 | "metadata": { 815 | "id": "yzmHo9AHxhff" 816 | }, 817 | "source": [ 818 | "with open('/content/drive/My Drive/Python+for+Financial+Analysis+-+Course+Package/Part 1. Python Programming Fundamentals/S_P500_Stock_Data.csv') as f:\n", 819 | " readCSV = csv.reader(f, delimiter = ',')\n", 820 | " data = list(readCSV)" 821 | ], 822 | "execution_count": 27, 823 | "outputs": [] 824 | }, 825 | { 826 | "cell_type": "code", 827 | "metadata": { 828 | "id": "5gflv-5oQSQg", 829 | "outputId": "bd05766d-c1a0-40fd-92c6-d294a7e78eb2", 830 | "colab": { 831 | "base_uri": "https://localhost:8080/" 832 | } 833 | }, 834 | "source": [ 835 | "data[0]" 836 | ], 837 | "execution_count": 29, 838 | "outputs": [ 839 | { 840 | "output_type": "execute_result", 841 | "data": { 842 | "text/plain": [ 843 | "['Interest Rates', 'Employment', 'S&P 500 Price']" 844 | ] 845 | }, 846 | "metadata": { 847 | "tags": [] 848 | }, 849 | "execution_count": 29 850 | } 851 | ] 852 | }, 853 | { 854 | "cell_type": "code", 855 | "metadata": { 856 | "id": "um4wsztKQSSx", 857 | "outputId": "05198ed6-656e-4dc7-dc01-fc7a08f747b9", 858 | "colab": { 859 | "base_uri": "https://localhost:8080/" 860 | } 861 | }, 862 | "source": [ 863 | "data[0:6]" 864 | ], 865 | "execution_count": 31, 866 | "outputs": [ 867 | { 868 | "output_type": "execute_result", 869 | "data": { 870 | "text/plain": [ 871 | "[['Interest Rates', 'Employment', 'S&P 500 Price'],\n", 872 | " ['1.943859273', '55.41357113', '2206.680582'],\n", 873 | " ['2.258228944', '59.54630512', '2486.474488'],\n", 874 | " ['2.215862783', '57.41468676', '2405.868337'],\n", 875 | " ['1.977959542', '49.90835272', '2140.434475'],\n", 876 | " ['2.437722808', '52.03549192', '2411.275663']]" 877 | ] 878 | }, 879 | "metadata": { 880 | "tags": [] 881 | }, 882 | "execution_count": 31 883 | } 884 | ] 885 | }, 886 | { 887 | "cell_type": "code", 888 | "metadata": { 889 | "id": "AvkJGqpPQSOi" 890 | }, 891 | "source": [ 892 | "" 893 | ], 894 | "execution_count": null, 895 | "outputs": [] 896 | }, 897 | { 898 | "cell_type": "markdown", 899 | "metadata": { 900 | "id": "1YIpbzx8wrYj" 901 | }, 902 | "source": [ 903 | "# EXCELLENT JOB!" 904 | ] 905 | }, 906 | { 907 | "cell_type": "markdown", 908 | "metadata": { 909 | "id": "JOWd-_I8xlze" 910 | }, 911 | "source": [ 912 | "# MINI CHALLENGE SOLUTIONS:\n" 913 | ] 914 | }, 915 | { 916 | "cell_type": "markdown", 917 | "metadata": { 918 | "id": "PiBxzSjVxr4u" 919 | }, 920 | "source": [ 921 | "**MINI CHALLENGE #1:**\n", 922 | "- **Read the file 'fruits_input.txt'**\n", 923 | "- **compare the text file content to the list my_fruits = [\"Apple\", \"Pepper\", \"Orange\", \"Watermelon\", \"Tomatoes\"]**" 924 | ] 925 | }, 926 | { 927 | "cell_type": "code", 928 | "metadata": { 929 | "id": "45oMJBA2xvC5" 930 | }, 931 | "source": [ 932 | "my_fruits = [\"Apple\", \"Pepper\", \"Orange\", \"Watermelon\", \"Tomatoes\"]\n", 933 | "\n", 934 | "with open(\"/content/drive/My Drive/Colab Notebooks/Python & ML in Finance/Part 1. Python Programming Fundamentals/fruits_input.txt\", \"r\") as file:\n", 935 | " all_fruits = file.readlines()\n", 936 | "\n", 937 | "all_fruits = [char.rstrip('\\n') for char in all_fruits]\n", 938 | "Selected_fruits = [i for i in all_fruits if i in my_fruits]\n", 939 | "\n", 940 | "print(Selected_fruits)\n" 941 | ], 942 | "execution_count": null, 943 | "outputs": [] 944 | }, 945 | { 946 | "cell_type": "markdown", 947 | "metadata": { 948 | "id": "E-Ab25tzxuQU" 949 | }, 950 | "source": [ 951 | "**MINI CHALLENGE #2:**\n", 952 | "- **Read the CSV file entitled \"S&P500_Stock_data.csv\" and print out the heading**\n", 953 | "- **Print out the first 5 rows of data**" 954 | ] 955 | }, 956 | { 957 | "cell_type": "code", 958 | "metadata": { 959 | "id": "RKGDASZTxVYK" 960 | }, 961 | "source": [ 962 | "import csv\n", 963 | "with open(\"/content/drive/My Drive/Colab Notebooks/Python & ML in Finance/Part 1. Python Programming Fundamentals/S&P500_Stock_Data.csv\", \"r\") as csvfile:\n", 964 | " readCSV = csv.reader(csvfile, delimiter=',')\n", 965 | " stock = list(readCSV)\n", 966 | " " 967 | ], 968 | "execution_count": null, 969 | "outputs": [] 970 | }, 971 | { 972 | "cell_type": "code", 973 | "metadata": { 974 | "id": "f38DGWN6xXz7" 975 | }, 976 | "source": [ 977 | "print(stock)" 978 | ], 979 | "execution_count": null, 980 | "outputs": [] 981 | }, 982 | { 983 | "cell_type": "code", 984 | "metadata": { 985 | "id": "H6wfbUS4xX2Y" 986 | }, 987 | "source": [ 988 | "print(stock[0])" 989 | ], 990 | "execution_count": null, 991 | "outputs": [] 992 | }, 993 | { 994 | "cell_type": "code", 995 | "metadata": { 996 | "id": "vPW5JHLExaJG" 997 | }, 998 | "source": [ 999 | "selected = []\n", 1000 | "for row in stock[1:6]:\n", 1001 | " selected.append(row)" 1002 | ], 1003 | "execution_count": null, 1004 | "outputs": [] 1005 | }, 1006 | { 1007 | "cell_type": "code", 1008 | "metadata": { 1009 | "id": "X7R2RDmkxaLQ" 1010 | }, 1011 | "source": [ 1012 | "selected" 1013 | ], 1014 | "execution_count": null, 1015 | "outputs": [] 1016 | }, 1017 | { 1018 | "cell_type": "code", 1019 | "metadata": { 1020 | "id": "yfrWoZwxwojy" 1021 | }, 1022 | "source": [ 1023 | "" 1024 | ], 1025 | "execution_count": null, 1026 | "outputs": [] 1027 | } 1028 | ] 1029 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # “The Complete Python and Machine Learning for Financial Analysis” course in which you will learn everything you need to develop practical real-world finance/banking applications in Python! 2 | 3 | 1. The course is divided into 3 main parts covering python programming fundamentals, financial analysis in Python and AI/ML application in Finance/Banking Industry. A detailed overview is shown below: 4 | 5 | a) Part #1 – Python Programming Fundamentals: Beginner’s Python programming fundamentals covering concepts such as: data types, variables assignments, loops, conditional statements, functions, and Files operations. In addition, this section will cover key Python libraries for data science such as Numpy and Pandas. Furthermore, this section covers data visualization tools such as Matplotlib, Seaborn, Plotly, and Bokeh. 6 | 7 | b) Part #2 – Financial Analysis in Python: This part covers Python for financial analysis. We will cover key financial concepts such as calculating daily portfolio returns, risk and Sharpe ratio. In addition, we will cover Capital Asset Pricing Model (CAPM), Markowitz portfolio optimization, and efficient frontier. We will also cover trading strategies such as momentum-based and moving average trading. 8 | 9 | c) Part #3 – AI/Ml in Finance/Banking: This section covers practical projects on AI/ML applications in Finance. We will cover application of Deep Neural Networks such as Long Short Term Memory (LSTM) networks to perform stock price predictions. In addition, we will cover unsupervised machine learning strategies such as K-Means Clustering and Principal Components Analysis to perform Baking Customer Segmentation or Clustering. Furthermore, we will cover the basics of Natural Language Processing (NLP) and apply it to perform stocks sentiment analysis. 10 | -------------------------------------------------------------------------------- /S_P500_Stock_Data.csv: -------------------------------------------------------------------------------- 1 | Interest Rates,Employment,S&P 500 Price 2 | 1.943859273,55.41357113,2206.680582 3 | 2.258228944,59.54630512,2486.474488 4 | 2.215862783,57.41468676,2405.868337 5 | 1.977959542,49.90835272,2140.434475 6 | 2.437722808,52.03549192,2411.275663 7 | 2.143636835,56.06059825,2187.344909 8 | 2.148646786,51.51320834,2263.049249 9 | 2.176183572,53.4759086,2281.496374 10 | 2.125351611,63.66842224,2355.163011 11 | 2.225681934,56.99339607,2326.330337 12 | 1.814687751,55.36178043,2078.553895 13 | 2.281897215,58.48475241,2337.504507 14 | 2.426737871,55.7093282,2485.774097 15 | 2.259270476,61.8872018,2478.413528 16 | 2.38801924,66.55127056,2665.00807 17 | 1.715103596,60.20251695,2057.393366 18 | 2.392425284,60.57381954,2423.590565 19 | 2.388766722,58.26132918,2605.470983 20 | 2.25666065,52.77316693,2303.851816 21 | 2.089815376,48.80721748,2095.440317 22 | 2.348535874,58.65942761,2495.24303 23 | 1.751579397,54.1482556,1871.361622 24 | 2.043664892,55.88532564,2213.4959 25 | 1.925000309,50.65959264,2173.474255 26 | 2.555488648,60.66742545,2505.572687 27 | 2.327856795,52.32411313,2394.960918 28 | 2.470797697,66.41062676,2607.334886 29 | 2.493477616,62.36990787,2711.535184 30 | 2.019271886,61.30918176,2287.893451 31 | 2.150985995,58.01026516,2301.183322 32 | 2.346574367,60.24485249,2578.928716 33 | 2.234971973,66.43079774,2400.838075 34 | 2.318586182,58.47312625,2513.761261 35 | 2.471254469,54.27216682,2499.709024 36 | 2.429504212,55.96780222,2511.585107 37 | 1.86233331,53.5464955,2056.66532 38 | 2.08177214,59.49549477,2322.506869 39 | 2.078313338,54.70496374,2214.438648 40 | 2.035760712,58.20633629,2293.011223 41 | 2.153788109,53.79384887,2284.377552 42 | 2.368019487,52.15390967,2395.449084 43 | 2.045156301,55.33238241,2232.631281 44 | 2.294886883,62.08243198,2486.886187 45 | 1.946422633,55.64811342,2128.56097 46 | 2.378292866,53.86825132,2330.264882 47 | 1.907588612,65.05663684,2179.832793 48 | 2.377799098,61.38839068,2454.376297 49 | 1.821981194,64.82714703,2136.421802 50 | 1.955478524,54.34531977,2218.440607 51 | 2.241784674,52.03312155,2243.357033 52 | 2.421366293,64.37299939,2583.772535 53 | 2.220100767,61.48700303,2467.225659 54 | 2.288027409,51.35831748,2306.250551 55 | 2.273335108,50.81248482,2266.485265 56 | 2.364973084,54.6110588,2400.575035 57 | 1.864920817,52.86351173,2077.039535 58 | 2.413087541,63.18494849,2615.057826 59 | 2.326110511,58.05225193,2473.534512 60 | 2.206374602,58.96669179,2409.419529 61 | 2.331762059,51.20679921,2365.334582 62 | 2.158107403,56.94161567,2380.778616 63 | 2.061519772,54.72591953,2166.298978 64 | 2.236911068,63.54432256,2465.86378 65 | 1.784757431,60.11927834,2057.81389 66 | 2.47840331,55.5088784,2479.967865 67 | 2.05421397,58.02172807,2271.569659 68 | 1.908078191,58.96261179,2097.923278 69 | 2.402099755,50.3266607,2380.185822 70 | 2.294610032,50.27355882,2226.020117 71 | 2.409822884,53.24919914,2375.003281 72 | 2.043082841,53.48238165,2180.527688 73 | 2.622911123,60.63401438,2645.002278 74 | 2.050541378,64.34248057,2317.91969 75 | 2.195249379,59.31349642,2442.427461 76 | 2.098943088,64.00034445,2282.299179 77 | 1.85685153,56.44881372,2152.663792 78 | 2.621272516,52.03897077,2574.124645 79 | 2.295624495,50.94161524,2255.973064 80 | 2.178268438,54.10428039,2372.122602 81 | 2.406869154,58.72186579,2594.06085 82 | 2.311120221,64.27205212,2480.937937 83 | 2.470552526,55.68649232,2571.693563 84 | 2.271577133,59.68830324,2334.154947 85 | 2.12496735,64.26883054,2265.169285 86 | 1.660759847,66.92387361,2054.691801 87 | 1.773872485,57.36754015,2049.656586 88 | 2.041120835,51.30814528,2085.504722 89 | 1.968933428,53.71421715,2209.452719 90 | 2.070884786,60.6799453,2303.32136 91 | 2.352625056,59.84641605,2529.900433 92 | 2.443545264,56.28646245,2485.6915 93 | 2.225766656,64.01105093,2418.650394 94 | 1.833505757,58.45932801,2034.585802 95 | 2.438262745,52.66539942,2542.75586 96 | 2.284511216,55.2745549,2309.845969 97 | 2.111879527,54.06753267,2191.584236 98 | 2.084106378,52.91155559,2232.101356 99 | 2.135534162,54.10915815,2298.678378 100 | 2.605900429,54.86805723,2604.021451 101 | 1.847721715,50.11801365,2030.255444 102 | 2.170306259,60.42140921,2289.292493 103 | 2.459078859,55.7204476,2509.289637 104 | 2.115135911,51.08292272,2230.842487 105 | 2.319902806,50.89276452,2303.805232 106 | 1.991557623,53.39366326,2156.482899 107 | 2.264448116,52.89878002,2380.175799 108 | 2.610948001,46.05011863,2476.65227 109 | 2.166098413,44.99453087,2162.338172 110 | 2.066675853,55.05282488,2176.740194 111 | 2.177803263,59.32541672,2406.292521 112 | 2.180295512,62.90085347,2460.407246 113 | 1.945092899,53.78960988,2109.002333 114 | 2.032212666,58.22677355,2171.367227 115 | 2.261475517,58.53993413,2303.542275 116 | 2.14331697,51.91215243,2395.641572 117 | 1.80668742,60.80176825,2074.573461 118 | 2.44183537,62.55163564,2607.092049 119 | 1.760154495,54.68931236,1952.001588 120 | 2.616097718,57.50722319,2705.513622 121 | 2.442330616,67.75786786,2612.254563 122 | 2.646124006,54.03389014,2534.912862 123 | 2.273142864,60.93963902,2412.288762 124 | 1.968373633,56.02097872,2204.136374 125 | 2.12431105,58.79116463,2282.644134 126 | 2.021397885,55.2605442,2192.103402 127 | 1.92923651,50.49982763,1973.926154 128 | 2.128558032,61.02146222,2257.011706 129 | 2.378962477,48.67982369,2452.017895 130 | 2.42850793,53.89454328,2394.950908 131 | 2.196862273,61.00398738,2425.46489 132 | 2.187851098,57.05541748,2408.56898 133 | 2.05246053,55.89918925,2224.519934 134 | 2.185120402,62.6180842,2379.686276 135 | 2.136878442,59.05170993,2187.179064 136 | 1.843735945,50.12167659,2025.598777 137 | 2.172567818,46.05813455,2153.545306 138 | 2.341400548,58.63951045,2472.159451 139 | 2.0760971,56.83870333,2218.422199 140 | 2.22915877,52.65658748,2276.325004 141 | 2.514393448,56.10806954,2593.14799 142 | 2.657335394,59.85671495,2716.311471 143 | 2.419850891,57.89992158,2478.61552 144 | 2.363962499,47.32946944,2268.189407 145 | 2.343674874,55.46783139,2509.850372 146 | 2.333038706,65.77893298,2520.57354 147 | 2.064005195,50.85327817,2164.214005 148 | 2.081948765,47.29996815,2157.097786 149 | 2.64807603,57.1026513,2627.860796 150 | 2.032081772,54.86223795,2168.981677 151 | 2.176973998,58.15190041,2276.957169 152 | 2.363482296,52.05028455,2440.4093 153 | 1.84999776,56.55766273,2058.115839 154 | 2.091777438,57.48712461,2214.110293 155 | 2.512354933,56.31731339,2569.794605 156 | 1.914657259,62.0047447,2086.121167 157 | 2.322631139,49.66722608,2352.982842 158 | 2.43786219,52.22141381,2503.055963 159 | 2.600144175,56.99936221,2574.397709 160 | 2.465974471,52.27301649,2354.417867 161 | 1.89004412,50.67715321,2001.784387 162 | 1.712212237,56.73553479,1995.185139 163 | 2.140238659,50.26808983,2238.404644 164 | 1.837004915,53.92830156,1943.793389 165 | 2.055642188,56.19187647,2126.587693 166 | 2.010668059,54.99090347,2249.519871 167 | 2.544631725,54.76033881,2632.854301 168 | 2.762526659,54.00208102,2666.551254 169 | 1.877022072,59.44633603,2232.295953 170 | 2.331852436,56.20723576,2413.487824 171 | 2.503646649,57.17923864,2488.543702 172 | 2.038402813,51.62519513,2193.473502 173 | 2.089560707,54.36439503,2234.08287 174 | 1.952422273,59.69831335,2104.917757 175 | 2.158421332,56.48505376,2320.358026 176 | 2.042724341,52.38699638,2352.350948 177 | 2.069095758,63.55140667,2295.615096 178 | 2.009803999,53.49032062,2069.924132 179 | 2.264006944,61.41779743,2394.704181 180 | 2.120746599,54.06488404,2151.547359 181 | 2.214800171,62.16522029,2351.681943 182 | 2.032820882,64.89850252,2358.237121 183 | 1.844029124,55.82576535,2176.177733 184 | 1.841111254,61.47057218,2178.1396 185 | 1.87996797,54.88422487,2089.128863 186 | 2.459225611,59.66403144,2608.966825 187 | 1.786630643,52.33792187,1985.340137 188 | 2.408882034,45.69616356,2326.964945 189 | 2.297351667,56.90405262,2312.23451 190 | 2.095383247,56.07820524,2239.206909 191 | 2.209058151,55.24150763,2348.810172 192 | 2.05965948,59.86023059,2161.306722 193 | 2.092564019,60.85477057,2339.59286 194 | 2.166831994,53.23690391,2255.418313 195 | 2.136789467,64.2912004,2329.882363 196 | 2.090317522,64.07359663,2358.901395 197 | 2.177418883,60.90105401,2432.084136 198 | 1.980432166,61.7958101,2201.536885 199 | 2.283097654,57.65995877,2426.426366 200 | 2.457662992,56.56657895,2547.353453 201 | 2.352227725,62.71220937,2561.39775 202 | 2.213058435,63.25701786,2336.841547 203 | 2.0272128,43.62047942,2126.682907 204 | 2.510989705,45.74977426,2352.911023 205 | 2.236186974,59.41473136,2408.579162 206 | 2.179771321,68.49901177,2470.338095 207 | 1.755903252,50.97161185,1868.098672 208 | 1.936335228,58.77120311,2157.14983 209 | 2.15536877,48.06708172,2214.343525 210 | 2.485933848,58.35450875,2561.197344 211 | 1.842986647,59.19159809,2019.098479 212 | 2.578039253,53.04965364,2551.433973 213 | 2.578466991,57.25486468,2586.350786 214 | 2.455536421,54.50010104,2426.264985 215 | 2.336231542,55.97544037,2470.666453 216 | 2.121484839,60.94369289,2211.922757 217 | 1.614194781,61.40304241,2040.970859 218 | 2.105701073,52.40854265,2325.68854 219 | 1.895641652,48.98759428,2093.838529 220 | 1.861334881,41.8549385,2020.425911 221 | 1.809789928,54.5478481,1939.222258 222 | 2.264367806,53.4950671,2290.521292 223 | 1.802931891,61.70173894,2184.083606 224 | 1.951372748,60.6726625,2217.309238 225 | 2.037689971,54.05684936,2280.315943 226 | 2.488458677,57.87947939,2451.831448 227 | 2.144937444,54.46240152,2290.537965 228 | 2.094951519,56.82841462,2160.049356 229 | 1.583698255,60.69731223,1960.360276 230 | 2.325160542,69.70686437,2555.649348 231 | 2.059281896,54.45681336,2290.744216 232 | 1.952570708,60.13240275,2113.993471 233 | 2.544164194,54.43475302,2416.199762 234 | 1.917374459,64.13883015,2317.419986 235 | 2.501127166,55.55272241,2527.086457 236 | 2.246987354,64.66627192,2363.088234 237 | 2.00323036,55.83348935,2240.762386 238 | 2.060210399,58.42618556,2226.194403 239 | 2.486449568,61.16902353,2566.069872 240 | 2.115801309,57.47035296,2326.787663 241 | 2.440046043,49.01445243,2401.643137 242 | 1.819379176,56.75496998,2063.781192 243 | 2.51345978,52.88800684,2443.871948 244 | 1.734531984,49.4551693,1989.292736 245 | 2.251242955,51.34754592,2190.704632 246 | 2.091590871,53.83638033,2093.76599 247 | 2.255539083,52.67727254,2376.460636 248 | 2.210104164,51.77279316,2326.128039 249 | 2.513982133,52.63442722,2483.672065 250 | 1.816132525,58.88084459,2045.1672 251 | 2.274454577,52.68536787,2368.337374 252 | 2.234480324,68.87741053,2509.370672 253 | 2.455078272,54.31157305,2560.583189 254 | 2.410756614,59.05970102,2625.632502 255 | 2.374094495,51.33819059,2359.311496 256 | 1.975144213,60.53515359,2226.267966 257 | 1.895897852,56.81831992,2189.67771 258 | 2.046985966,57.19988731,2130.3516 259 | 2.381673105,60.23915166,2563.101932 260 | 2.304482454,62.4080224,2479.378679 261 | 2.421699153,53.11495147,2406.357106 262 | 2.438612408,54.52668775,2432.226364 263 | 2.030477255,53.78186882,2054.584569 264 | 1.884660815,60.50740568,2055.510396 265 | 2.209819624,44.26089047,2223.491314 266 | 1.874197019,61.70893839,2161.681464 267 | 2.104577385,57.97735361,2258.252471 268 | 2.146660672,52.94121008,2303.512058 269 | 2.049008008,56.03195557,2199.720666 270 | 1.669439154,54.89810937,1990.079042 271 | 2.236707377,47.25604071,2249.463406 272 | 1.889670286,57.61121304,2175.005338 273 | 1.938483212,59.17304051,2280.188292 274 | 1.953693442,50.62758429,2129.542585 275 | 2.285949602,48.08180293,2204.332189 276 | 2.571107133,59.24279309,2587.525938 277 | 2.409319433,57.38964669,2423.667379 278 | 2.557272383,58.02986548,2614.204476 279 | 2.220435158,51.56181123,2285.313963 280 | 2.425350762,58.69199167,2537.219432 281 | 2.295330588,60.4609499,2455.322645 282 | 2.034233742,56.54791441,2187.847437 283 | 1.82135961,52.99445357,1953.971884 284 | 2.748589204,49.38248685,2662.466996 285 | 2.087141983,53.20816951,2194.463651 286 | 2.730958691,57.43574436,2703.450322 287 | 2.166227268,49.46667263,2264.499374 288 | 1.969469443,59.45325984,2307.073056 289 | 1.978940642,54.36737634,2191.833841 290 | 2.004312261,56.31963292,2145.927833 291 | 2.263229275,66.8891598,2510.021088 292 | 1.981246005,51.36563002,2009.165061 293 | 2.218393144,57.72040061,2344.076456 294 | 2.212539258,61.52375052,2382.506755 295 | 2.128799593,55.18607346,2331.29325 296 | 2.133134264,59.66271778,2310.295544 297 | 2.299448528,62.88498127,2500.830946 298 | 2.534131622,55.37102563,2527.753296 299 | 2.237709259,47.89888793,2311.856204 300 | 2.377631247,54.27636712,2286.002432 301 | 2.206932831,59.36730842,2491.859319 302 | 2.490939435,57.49900628,2596.897925 303 | 2.158595407,53.51767899,2374.302142 304 | 1.815492564,55.7013248,2065.514387 305 | 1.845592813,64.27401356,2134.683899 306 | 2.251801413,63.60304499,2431.691555 307 | 2.317509824,55.97041007,2548.820126 308 | 2.471602445,50.15757194,2430.900994 309 | 2.325085292,46.0543703,2364.170766 310 | 1.814464022,55.89960097,1932.712179 311 | 2.207383505,52.45368334,2225.267137 312 | 2.065958297,67.32633155,2312.796559 313 | 1.957455612,54.81731315,2091.145495 314 | 2.294109365,60.42992085,2411.861322 315 | 2.507191564,53.74900883,2478.846413 316 | 2.192313101,59.35272609,2448.401656 317 | 2.161489276,67.26825089,2490.712759 318 | 2.042070628,48.84218067,1968.758078 319 | 2.40759562,47.2066774,2514.830249 320 | 2.169592671,50.39316031,2229.127588 321 | 1.715219555,51.47309564,1939.696455 322 | 1.841500474,55.00368222,2007.296581 323 | 1.991109734,49.50010015,2083.726913 324 | 2.183515478,49.2014938,2186.216985 325 | 2.195648437,51.39929621,2280.54883 326 | 2.212417063,58.3791069,2312.651538 327 | 1.94291768,57.83248668,2098.664667 328 | 2.126698366,56.58596486,2348.263307 329 | 2.278576674,54.6669569,2418.457054 330 | 2.341818792,47.41014508,2346.131144 331 | 2.131763831,59.90327421,2256.753781 332 | 1.748955173,56.15680585,2028.547812 333 | 1.958816268,52.31444154,2106.392158 334 | 2.408621671,49.93645481,2467.185057 335 | 1.577665599,54.42385463,1875.591515 336 | 2.228644466,53.78208144,2371.181823 337 | 1.84198634,53.184923,2068.232301 338 | 2.584793453,54.00217453,2542.881203 339 | 2.016299848,55.3686512,2195.392436 340 | 2.110385313,66.79174925,2441.52338 341 | 2.154403055,47.88914538,2070.563176 342 | 1.752745603,65.16052595,2032.672119 343 | 2.004731963,56.1622269,2221.463646 344 | 1.824549682,48.05014816,1957.698843 345 | 2.636279476,52.49166694,2676.678356 346 | 1.763907752,55.24971749,1984.05481 347 | 2.070017451,54.9887428,2245.493532 348 | 2.159510469,53.55458142,2181.068274 349 | 2.447644582,57.69915545,2529.458806 350 | 2.313274464,56.59745438,2404.232249 351 | 2.379299084,51.67003533,2416.55307 352 | 2.101248144,55.64614087,2175.143564 353 | 2.328897655,57.58145532,2408.047948 354 | 1.943040717,50.29910536,1967.949728 355 | 2.097492253,52.89799653,2263.997223 356 | 2.128554825,53.34036305,2204.201677 357 | 2.158610742,54.33475086,2303.937315 358 | 2.458434332,54.91736119,2582.525839 359 | 2.533727845,53.41185294,2566.479638 360 | 2.139743067,53.80829552,2281.062912 361 | 2.017402899,57.29327435,2356.430255 362 | 2.822810035,64.09920539,2961.657934 363 | 2.299389677,54.94374018,2446.451123 364 | 2.71839974,58.30946249,2730.081332 365 | 2.627876643,63.08184851,2680.158012 366 | 2.237967703,62.00870345,2432.116523 367 | 2.320442514,48.28585913,2265.236799 368 | 1.948217587,56.68176695,2138.087162 369 | 2.333277084,54.82293367,2376.31297 370 | 2.258902505,57.15298829,2415.441991 371 | 2.420507213,63.19886452,2494.795268 372 | 2.329550674,50.47810884,2280.141117 373 | 2.29666498,55.55901968,2308.532775 374 | 2.064607244,47.75625153,2117.755584 375 | 2.411521251,56.04080003,2569.286651 376 | 2.068705139,55.95692792,2155.967218 377 | 1.631978614,60.74189173,1975.32903 378 | 2.096176369,60.37552099,2344.194806 379 | 2.031369751,63.24126805,2264.834812 380 | 2.131330128,53.12438024,2250.779895 381 | 2.012319501,51.42723158,2142.015273 382 | 1.944675402,57.03401795,2064.256907 383 | 2.081998394,50.89555616,2076.644049 384 | 2.004016302,56.93064675,2164.921093 385 | 2.435220022,57.71444989,2586.807488 386 | 2.207321135,40,2230.371385 387 | 2.286087683,63.38261104,2548.587322 388 | 2.473495552,53.3037397,2512.975833 389 | 1.520185509,59.73111626,1811.866414 390 | 1.846378785,55.84046171,2064.879708 391 | 2.357109197,60.6608534,2457.236345 392 | 1.979698128,51.03102416,2124.610963 393 | 2.320916438,50.27758608,2217.375113 394 | 2.081193066,52.94034065,2240.319822 395 | 2.295570225,56.98922773,2336.710981 396 | 2.096921682,55.34997599,2247.175725 397 | 1.834614287,62.67009769,2138.250789 398 | 2.228567335,58.38983052,2420.199094 399 | 2.146790553,51.03210389,2252.963892 400 | 2.054755967,54.81694063,2133.155735 401 | 1.875154106,56.96834693,2131.643743 402 | 2.221840138,57.92678143,2395.517804 403 | 2.177394807,55.88349551,2260.209586 404 | 2.208271098,59.16683505,2333.789349 405 | 2.307734234,63.44060707,2467.402219 406 | 2.259437572,56.14810581,2351.292891 407 | 2.231417923,55.43232384,2288.032975 408 | 2.534081317,61.51564755,2671.924032 409 | 2.43414985,56.87728832,2449.615039 410 | 2.359037936,55.28554606,2352.482742 411 | 2.645484565,56.56218689,2616.570183 412 | 2.016317976,56.62350301,2207.564493 413 | 2.095872781,64.89674913,2262.460091 414 | 1.943892675,67.15511726,2242.91381 415 | 2.394475346,58.02168094,2540.832079 416 | 2.586505826,54.72972081,2644.053463 417 | 2.279704721,52.35413929,2230.992396 418 | 1.685744842,59.52336301,2008.920092 419 | 2.317700168,55.433041,2448.012282 420 | 2.148241918,51.25488051,2263.28668 421 | 2.316391712,51.66592345,2327.877353 422 | 2.02361448,52.99227419,2064.820184 423 | 2.206733211,58.92596478,2466.452749 424 | 1.659613423,54.5063495,1940.70954 425 | 2.357340275,54.97424489,2459.794597 426 | 2.343152753,63.18231366,2536.662687 427 | 2.155317719,62.2283676,2358.711265 428 | 1.94894847,54.2668027,2050.11637 429 | 2.910198184,60.9763234,2813.207807 430 | 2.229230935,45.66109477,2244.953952 431 | 2.217773597,53.49579978,2241.830339 432 | 2.1038789,53.47304199,2287.545988 433 | 1.937095942,58.85889674,2172.602471 434 | 1.920320647,46.12783552,1890.0438 435 | 2.238857236,54.05502395,2315.355427 436 | 2.529669127,51.40285935,2469.49294 437 | 1.821876602,51.24253913,1860.986179 438 | 2.19013488,53.15684874,2354.905933 439 | 2.128698621,52.10235525,2266.46354 440 | 2.099504111,51.85822793,2189.241938 441 | 2.556871995,53.24984223,2481.442932 442 | 1.909554923,62.83565323,2217.985006 443 | 2.332760965,59.69281396,2513.132909 444 | 2.13468586,58.5994848,2305.477601 445 | 2.666853773,53.75639002,2744.341038 446 | 1.815993835,44.68918386,1897.95002 447 | 1.775419257,61.69843662,2025.584062 448 | 2.216937609,59.34704537,2246.138405 449 | 2.127391371,63.09337535,2330.839703 450 | 2.124184856,55.48633945,2201.329585 451 | 2.264032421,54.50081433,2401.52261 452 | 2.200251107,55.55381011,2294.672153 453 | 1.975164067,55.73335597,2131.611928 454 | 1.901344225,53.52842585,2040.17796 455 | 2.628901322,63.58004529,2692.172185 456 | 2.438620643,66.68326531,2528.5072 457 | 2.221970158,50.80583034,2255.098613 458 | 2.158515505,51.11968601,2302.98708 459 | 2.073476004,48.04531198,2104.9998 460 | 1.825358042,56.51203528,2118.239909 461 | 1.961815154,46.01328354,1910.491129 462 | 2.411058287,59.21203719,2604.462391 463 | 2.239113239,48.76213405,2249.398812 464 | 2.585961988,54.26775326,2563.263411 465 | 2.081658967,50.336129,2149.177712 466 | 2.137104767,54.70406736,2246.840687 467 | 2.140607981,61.83799614,2274.098283 468 | 1.988537591,53.17024727,2099.408814 469 | 1.836668775,56.90948154,2093.725978 470 | 2.247479148,58.71620451,2269.008012 471 | 2.593687463,54.42640663,2539.616375 472 | 2.219437258,55.92141091,2301.228412 473 | 2.17933907,58.08113156,2381.610775 474 | 2.33157812,55.31600667,2462.140255 475 | 2.875356059,56.45156361,2714.526238 476 | 2.244395932,58.65893567,2358.693133 477 | 1.884734113,52.99482684,2149.236151 478 | 2.350532565,60.33056425,2462.129912 479 | 2.304166979,53.67059019,2366.103052 480 | 2.286990363,58.61039087,2364.793414 481 | 2.194332432,56.17655959,2357.123376 482 | 2.001970025,55.35829993,2213.870263 483 | 1.770189765,62.12256867,2197.061554 484 | 2.086799694,55.96947305,2329.202713 485 | 2.150428689,57.1353044,2270.590881 486 | 2.219613237,55.24614939,2372.028186 487 | 2.003310731,55.44744989,2141.297238 488 | 2.391626695,56.15965573,2436.006164 489 | 2.087344993,53.3202402,2251.595945 490 | 2.610186114,58.52202689,2631.082401 491 | 2.230395309,63.42719273,2390.633533 492 | 1.917328363,45.92869054,1990.596268 493 | 1.5,58.3239933,1800 494 | 2.073937955,65.98354639,2429.316049 495 | 2.081163471,58.0028868,2273.90478 496 | 1.99728421,55.19635312,2129.685155 497 | 2.221677048,55.96320299,2406.175541 498 | 2.48998004,55.1540618,2535.149493 499 | 1.842950285,44.28681264,1829.87691 500 | 2.500401854,54.09483594,2608.523191 501 | 2.14043625,51.16670155,2234.63035 502 | 2.349395175,50.97460707,2280.704652 503 | 2.609063519,58.77622516,2625.102056 504 | 2.198281206,58.9305176,2214.10772 505 | 2.595367319,45.56931327,2504.999779 506 | 2.436590616,58.36991929,2447.909806 507 | 1.866019576,52.1364417,2207.331004 508 | 2.048311442,51.00267893,2056.257594 509 | 2.09708156,57.06702145,2190.898403 510 | 2.177188059,58.71022265,2296.875718 511 | 1.843877655,59.6938675,2072.484866 512 | 2.220782854,53.35684553,2395.992657 513 | 2.098052591,59.07404995,2188.320015 514 | 2.257465343,58.40194874,2429.328659 515 | 2.154780892,61.50260421,2274.612243 516 | 2.145268025,48.54584059,2150.221644 517 | 2.700582116,55.10973491,2760.071808 518 | 2.424922286,69.42787149,2670.193426 519 | 2.360406621,56.19432634,2309.639821 520 | 1.777087313,51.43788247,1972.252223 521 | 2.230992813,57.58432503,2265.641759 522 | 1.986719542,62.87651302,2319.460816 523 | 2.362038336,48.5402448,2351.05837 524 | 2.458096496,57.9407527,2654.195332 525 | 2.434960998,52.66346332,2415.958025 526 | 2.506804339,61.37133155,2606.268584 527 | 2.508686735,55.092796,2535.411652 528 | 2.056775052,55.99323152,2319.187266 529 | 1.9980264,46.34161726,1968.593763 530 | 2.333897805,49.54986872,2275.504259 531 | 2.54084853,48.43743664,2523.331829 532 | 1.907019269,56.41274065,1987.664721 533 | 2.255181812,47.21024078,2234.287319 534 | 2.147138875,56.1293523,2277.203011 535 | 2.287295282,56.40548848,2447.594216 536 | 1.948447098,65.44000171,2202.852366 537 | 2.459592251,57.90151436,2615.466509 538 | 2.314809539,57.53135688,2377.864371 539 | 2.245872925,55.60318233,2380.370125 540 | 2.133354464,57.39535965,2253.551734 541 | 1.912627087,54.21607974,2091.839822 542 | 1.944358274,58.97468361,2225.042365 543 | 2.365557876,52.62065712,2368.032181 544 | 2.198146386,61.28649351,2382.837338 545 | 1.552546766,56.75458027,1818.067836 546 | 2.058277127,56.64310624,2245.261305 547 | 1.628710716,52.53876921,1911.679724 548 | 2.466071766,53.81838042,2519.577901 549 | 2.605130176,55.62473784,2716.460755 550 | 2.264140332,50.08352692,2299.7104 551 | 1.963275498,65.21790963,2270.523533 552 | 2.239091429,51.78857681,2294.267522 553 | 1.899331786,62.96071331,2164.735501 554 | 2.430620751,50.90894445,2399.517854 555 | 2.35109714,51.29484813,2397.280286 556 | 1.943679448,54.12589212,2072.532283 557 | 2.406421307,53.2054906,2447.679703 558 | 2.238479524,55.0085579,2367.161373 559 | 1.886175954,49.06864913,1977.181068 560 | 2.36052923,58.74869132,2522.769866 561 | 1.855734452,58.26360486,2094.55809 562 | 2.217368402,51.72715034,2267.716197 563 | 2.613129764,59.50424288,2556.490037 564 | 1.893123432,56.97627991,2117.817804 565 | 2.38575674,51.76458457,2362.379771 566 | 2.465829496,62.84473725,2563.125423 567 | 1.975905727,57.14704686,2271.519171 568 | 2.010143848,56.10259245,2197.51133 569 | 1.913690967,49.03023575,2006.779946 570 | 2.304442864,54.87024351,2306.332991 571 | 2.615080474,53.64724981,2719.577593 572 | 2.209164837,54.42677228,2220.274957 573 | 1.722437465,55.81314179,2029.171766 574 | 2.274595549,57.90291755,2325.278257 575 | 1.868848892,54.70731626,2038.47876 576 | 2.341519503,56.70861622,2449.497672 577 | 2.370564115,53.1659584,2382.864958 578 | 2.035334765,61.55616027,2301.31108 579 | 1.902074875,56.29430148,2088.375069 580 | 2.189431598,53.04143697,2267.103808 581 | 2.105974443,59.54254159,2387.61161 582 | 1.913746368,56.47516015,2034.833667 583 | 2.602290465,57.27682426,2527.212642 584 | 2.445536908,51.89497924,2412.126316 585 | 2.226455865,53.3500209,2291.60454 586 | 1.838465572,53.45228546,2038.476313 587 | 2.197508267,59.02924326,2261.549693 588 | 1.954255835,50.50512589,2004.574434 589 | 2.264835684,60.31669198,2358.937114 590 | 2.108495352,58.73866654,2268.15783 591 | 2.111428515,50.57244514,2222.955525 592 | 2.588365899,48.88970424,2556.018055 593 | 2.162411272,61.89079578,2374.976312 594 | 2.7785985,53.77474083,2761.767184 595 | 2.176136664,52.27645705,2287.412304 596 | 2.064196476,54.81729024,2266.33158 597 | 1.901681615,52.57173966,1945.010383 598 | 2.172734582,51.43592502,2245.935245 599 | 2.000319298,53.52603812,2070.397387 600 | 2.275859074,64.76971603,2593.022582 601 | 1.798799582,66.78744297,2106.275674 602 | 2.260445545,51.39731393,2249.426759 603 | 1.938090408,59.62583885,2215.718059 604 | 2.47827999,53.53617292,2462.971233 605 | 2.214407954,54.5969293,2347.988019 606 | 2.604897279,63.03684283,2721.53411 607 | 1.80579036,59.06952238,2045.289293 608 | 2.203897377,46.27157162,2192.925022 609 | 2.309712281,56.93516949,2306.459542 610 | 2.205751128,59.96138759,2320.415035 611 | 2.426777136,56.95152529,2634.859949 612 | 2.21608989,52.26373543,2314.05093 613 | 2.327081533,57.67779926,2356.612921 614 | 1.789671785,59.95795039,2126.110557 615 | 1.947455244,49.71433751,2101.112364 616 | 2.00891264,65.98203873,2355.333477 617 | 2.188232374,50.53895618,2253.158001 618 | 2.297676282,47.2527518,2298.132355 619 | 1.849942804,56.80708622,2079.956619 620 | 2.149501468,65.96918512,2378.592772 621 | 2.039147138,49.26949005,2100.927737 622 | 2.328507953,65.10191383,2588.532066 623 | 2.419170679,58.46744748,2540.497361 624 | 2.047991166,45.29427393,2121.109111 625 | 2.389348045,56.17544093,2418.07588 626 | 2.321609474,60.28171929,2409.79609 627 | 2.654264967,49.59111722,2628.455401 628 | 2.175099667,58.14130592,2289.185468 629 | 2.362125662,53.24148477,2309.459226 630 | 2.514151318,61.01098387,2605.809422 631 | 2.289740962,70,2669.413724 632 | 2.386069343,58.47474312,2532.816425 633 | 2.123545447,64.57604434,2355.192921 634 | 1.833060286,56.23212374,2004.687058 635 | 2.518894962,57.14835441,2618.369756 636 | 2.015126524,50.59761435,2114.861602 637 | 2.119271483,64.95540455,2392.917539 638 | 2.229345342,48.03322517,2318.890337 639 | 2.26655386,51.11994892,2325.153217 640 | 2.115192168,58.86498346,2378.590709 641 | 2.464952132,53.52896917,2554.458388 642 | 2.108795938,55.85337634,2246.562536 643 | 2.223329979,65.06959855,2401.509633 644 | 2.206168078,56.95332392,2282.970537 645 | 2.182093486,59.10932039,2418.48049 646 | 2.230329647,61.75946748,2358.825282 647 | 2.536453198,62.34661402,2674.075344 648 | 2.294757282,54.5354511,2371.265149 649 | 2.854088669,58.40754305,3000 650 | 1.985935104,54.13801509,2136.267794 651 | 2.502122009,51.50147491,2345.182079 652 | 2.22684545,51.81286638,2410.965587 653 | 2.070113348,60.34783129,2330.971718 654 | 1.724694167,66.47286418,2033.921399 655 | 1.770344098,53.17125296,2031.841984 656 | 2.183095454,56.57565183,2264.664692 657 | 2.067840366,60.73645158,2230.56173 658 | 2.604189262,52.85729896,2600.75919 659 | 1.908612201,60.86661196,2147.806229 660 | 2.214702595,54.21329993,2420.448765 661 | 2.262925056,52.07855565,2368.431646 662 | 2.298132752,58.50048432,2394.890495 663 | 1.943848348,57.27579848,2146.959244 664 | 2.09659416,55.79903393,2144.83262 665 | 2.052670181,57.10708533,2415.82493 666 | 2.036196143,50.15233266,2171.164097 667 | 2.017668856,51.48720336,2031.723125 668 | 2.50909625,59.09016581,2625.200578 669 | 2.234351636,59.13855129,2325.063521 670 | 2.423695137,65.40033657,2717.541698 671 | 2.252082881,55.93222686,2427.308062 672 | 2.311715804,55.82767845,2422.942425 673 | 1.826055638,57.95668989,2043.394926 674 | 2.307061125,55.81991299,2341.632103 675 | 2.209425807,52.54356889,2235.023281 676 | 2.30850771,60.56459664,2620.465951 677 | 2.166387558,50.90284027,2222.123775 678 | 2.126258096,42.59024956,2054.661826 679 | 2.700448026,55.14548535,2735.705706 680 | 2.359762254,50.84865714,2334.097117 681 | 2.085907361,56.79084569,2225.368249 682 | 1.981152054,50.51820751,1995.55406 683 | 2.255718675,61.4200527,2429.584175 684 | 2.723063458,59.20161862,2786.75257 685 | 1.918461603,63.62381312,2204.031531 686 | 2.07265027,55.17032425,2170.14926 687 | 1.909739933,60.35738248,2085.675173 688 | 2.28071225,62.81132136,2503.644412 689 | 2.378781512,59.22988193,2390.432134 690 | 2.036988171,55.59343897,2139.354533 691 | 2.145502321,57.3501823,2344.872901 692 | 2.040708191,51.23655032,2142.848999 693 | 1.954948579,52.74651951,2063.897571 694 | 2.368177431,45.29234747,2321.947646 695 | 2.294081788,58.57361666,2441.164248 696 | 2.39777578,54.56744061,2534.193817 697 | 2.28324438,53.85428009,2215.769849 698 | 2.329521556,59.75763284,2457.778052 699 | 2.68520417,58.61953652,2735.426271 700 | 2.12196782,57.93353192,2247.310457 701 | 2.262270281,59.61408861,2307.778921 702 | 2.163385615,62.66425645,2300.789398 703 | 2.159759966,57.14977726,2311.154906 704 | 2.035657804,60.23651494,2378.787803 705 | 2.326849321,60.90162933,2564.999176 706 | 2.283374101,53.75312959,2403.345743 707 | 1.725399372,59.04396629,2066.719804 708 | 1.819027509,50.70388382,1898.062783 709 | 1.956202864,61.46662069,2268.32237 710 | 2.528935863,51.02470924,2482.830269 711 | 1.812967324,52.4653138,2050.401538 712 | 2.538990987,52.38132747,2461.727516 713 | 2.489527522,60.3149488,2537.280025 714 | 2.18747346,66.77915031,2544.666569 715 | 2.054245457,57.88357441,2259.533756 716 | 2.093371785,49.8995228,2205.851343 717 | 2.510581364,57.0930445,2626.565867 718 | 2.081720731,59.11920097,2213.906675 719 | 2.710669895,56.47234795,2697.080546 720 | 2.659820896,55.83677135,2718.004463 721 | 2.225374496,60.79267059,2437.666322 722 | 1.922540324,58.06188874,2174.79229 723 | 2.548241363,47.86326248,2447.600914 724 | 2.223157513,65.25197411,2493.822027 725 | 1.897694246,54.98732495,2121.056357 726 | 2.33192749,56.4486669,2533.261367 727 | 2.049316094,52.42221482,2242.249019 728 | 2.344468868,56.94279698,2385.818507 729 | 2.654253068,48.2248861,2668.522152 730 | 1.937721746,54.89196263,2135.718495 731 | 2.148440166,63.15068074,2294.249443 732 | 2.240370968,55.04153448,2201.874293 733 | 1.986802709,55.37090712,2149.288416 734 | 2.054812901,54.90690719,2212.486168 735 | 2.253264669,51.16386159,2263.53482 736 | 1.879161381,60.65619535,2241.690182 737 | 2.505776456,57.00398496,2684.157055 738 | 2.30287198,53.91322809,2448.94019 739 | 2.688830076,64.52084118,2882.089818 740 | 2.306260209,49.29603452,2382.357678 741 | 2.228965154,50.03619325,2242.849473 742 | 2.092973339,54.40212693,2208.325043 743 | 1.826826784,61.02017038,2026.461281 744 | 2.457030989,59.5531963,2514.448514 745 | 2.547454407,49.65558564,2563.107584 746 | 2.292315529,47.76661002,2227.429936 747 | 2.08794026,58.49149326,2238.44823 748 | 1.746800052,58.47759389,2134.279361 749 | 2.18823917,51.25915742,2171.113464 750 | 2.370795143,58.25359733,2504.573873 751 | 2.457074367,61.52896639,2538.330074 752 | 2.825523822,57.69849546,2659.708857 753 | 2.273569831,47.36736163,2390.351844 754 | 1.915944551,54.27110739,2012.353658 755 | 2.360366169,56.0515862,2424.890502 756 | 1.951927321,61.85134127,2266.502144 757 | 2.515503458,54.18743329,2581.161415 758 | 2.375400218,52.76317838,2513.358114 759 | 1.826160659,56.71830418,2056.117673 760 | 1.958243055,56.14488792,2147.687163 761 | 2.099175373,44.54951056,2113.571787 762 | 2.275787183,51.19835906,2324.146613 763 | 1.942002948,58.1236757,2142.896297 764 | 2.294688286,57.73115533,2345.06889 765 | 1.987410487,52.55883026,2204.761129 766 | 2.14956276,57.32360969,2211.805473 767 | 1.699832346,57.25558983,2014.227589 768 | 3,53.61249241,2790.717444 769 | 2.371093896,60.10537182,2457.911646 770 | 2.797989568,55.51857047,2806.525663 771 | 2.078643557,58.11167307,2212.048212 772 | 2.497845062,57.99050057,2443.185475 773 | 2.395705888,51.3166685,2321.175613 774 | 1.78433008,50.86205231,1921.061432 775 | 1.892532678,55.20318436,2098.957804 776 | 1.986775217,56.15908422,2228.707718 777 | 2.315329919,58.9885637,2372.203884 778 | 2.374626201,45.48360217,2302.598911 779 | 2.089540355,51.60633921,2281.958219 780 | 2.301876049,64.52506273,2485.615142 781 | 2.356678506,63.27706765,2530.399462 782 | 2.078495267,62.75963702,2306.019536 783 | 1.892698737,56.92717371,2100.766236 784 | 2.205268013,52.03727511,2191.896982 785 | 2.418606872,56.70288809,2604.705284 786 | 2.164225094,66.27833496,2423.993057 787 | 2.536003644,64.26391035,2597.562055 788 | 1.7779566,54.58875072,1962.586672 789 | 2.162027559,57.7894993,2307.667557 790 | 2.119621203,62.45848383,2434.409305 791 | 1.881384822,61.81759291,2224.401004 792 | 2.370353906,57.53260047,2513.183597 793 | 2.357626509,61.47584133,2468.054986 794 | 1.894671871,57.37550814,2182.777261 795 | 2.075785086,63.2874683,2450.044635 796 | 1.982555299,65.94383169,2274.15879 797 | 2.709737542,49.04149252,2572.590836 798 | 2.005442976,55.88799854,2261.733772 799 | 2.014892912,51.43680651,2064.545306 800 | 2.021543857,48.47117419,2010.879432 801 | 2.181848685,60.60652939,2369.656778 802 | 2.154616295,53.0545232,2168.850828 803 | 2.208117233,58.50888006,2346.548207 804 | 2.271645145,59.18395553,2424.130614 805 | 2.266485076,58.41530354,2387.399751 806 | 2.391952008,61.66108027,2484.494446 807 | 2.295216998,59.95556307,2467.217237 808 | 2.461078798,56.87644978,2579.375796 809 | 2.047518466,57.9887085,2248.519297 810 | 1.960791616,59.86879961,2133.682183 811 | 2.163268803,63.55654013,2374.821325 812 | 1.947265636,61.32107979,2290.214944 813 | 2.521416831,62.20850921,2527.676619 814 | 2.316697913,60.86836085,2504.778396 815 | 1.970781395,57.54747871,2154.962659 816 | 2.439162795,65.86345362,2669.628301 817 | 2.361418467,62.07662097,2499.029019 818 | 2.448467486,52.90962911,2411.951996 819 | 2.611021714,60.46538004,2616.119908 820 | 2.092407493,58.75040637,2294.940155 821 | 1.846719068,60.17000999,2121.392623 822 | 2.102044897,48.93759096,2256.434644 823 | 2.247419672,55.1650644,2493.830094 824 | 1.74715718,57.16172353,2056.535955 825 | 2.558430806,62.7779247,2672.162986 826 | 2.187097489,57.03461645,2296.744987 827 | 2.507872667,59.59353227,2498.865065 828 | 2.359155681,50.70165135,2369.420389 829 | 2.317105011,53.11770555,2418.146203 830 | 2.167352068,62.45524621,2367.291188 831 | 2.204373332,54.91375395,2269.881977 832 | 2.372187745,53.5300371,2470.238056 833 | 2.089345855,58.37583453,2290.461187 834 | 2.316112178,63.97205582,2407.189813 835 | 2.277840398,53.9150776,2249.0204 836 | 2.251072985,54.4467519,2432.038805 837 | 2.329281719,55.91881252,2377.0565 838 | 1.68841987,49.02201588,1822.236989 839 | 2.181372931,57.12806896,2313.694484 840 | 1.948972723,49.61034898,2025.386061 841 | 2.279893541,54.63261815,2401.948822 842 | 2.617485407,46.04806614,2502.225437 843 | 1.887248096,46.27072613,2079.162986 844 | 2.355783694,58.12473033,2529.026103 845 | 2.072222306,60.80462178,2331.113443 846 | 2.379713092,56.88382307,2505.64593 847 | 2.609243349,51.81690548,2600.157557 848 | 2.145747006,61.38216019,2327.283786 849 | 2.438918882,47.80038945,2414.703713 850 | 2.036100705,57.5637274,2318.948444 851 | 2.099545862,57.81187023,2228.678985 852 | 2.279570935,53.51825842,2309.746169 853 | 2.161266079,53.64809057,2303.582132 854 | 2.209562475,55.7549549,2349.7774 855 | 2.231258379,50.72486026,2289.90274 856 | 2.330539925,60.82543351,2486.420472 857 | 2.212691685,50.6918674,2304.679267 858 | 2.41221411,63.02065345,2488.595541 859 | 1.619745685,58.49831987,2068.135127 860 | 2.811910442,57.70458825,2732.488463 861 | 1.950560011,54.18005491,2077.045715 862 | 2.522460058,57.63042166,2556.667869 863 | 2.547572047,56.136424,2652.889413 864 | 2.383899686,58.57576257,2493.42791 865 | 2.210034004,61.44973855,2409.475837 866 | 1.94594789,54.39702422,2033.164516 867 | 1.814590548,55.90518049,2047.108048 868 | 2.697697401,50.95954774,2577.297431 869 | 2.337777541,58.53179026,2397.221502 870 | 2.237340669,55.3423336,2303.31319 871 | 2.170327236,58.82457335,2353.079493 872 | 2.240776767,53.89103017,2332.274616 873 | 2.20368573,56.9715917,2374.19628 874 | 2.456990119,50.60119942,2489.362349 875 | 1.808657679,52.25026835,2039.919628 876 | 1.688500343,64.02392026,2041.952396 877 | 2.363324636,56.17510475,2395.212443 878 | 2.441280107,59.39704446,2560.500543 879 | 2.061805489,46.42443143,2170.667606 880 | 2.08890604,61.04816491,2398.341821 881 | 2.538773149,50.77546317,2497.279171 882 | 2.192704809,52.88940253,2313.120071 883 | 2.063067685,65.68248824,2344.342272 884 | 1.843025458,57.05846626,2006.057109 885 | 2.234792128,61.26524675,2372.415808 886 | 1.80802708,58.96299691,2065.398176 887 | 2.065682233,54.14214737,2240.801435 888 | 2.100985492,63.599018,2317.890582 889 | 2.099483389,55.216406,2219.485183 890 | 2.040288494,54.57539682,2115.299708 891 | 2.373199766,46.13051773,2360.683317 892 | 2.01894971,56.58188804,2161.369527 893 | 2.408168152,54.84893027,2427.819739 894 | 2.284000191,56.63515208,2459.81542 895 | 2.207086423,58.25732398,2333.199 896 | 2.248355193,56.5831953,2414.914951 897 | 1.899767635,51.66533062,2078.402807 898 | 2.596025229,45.2297572,2501.037865 899 | 2.388921827,51.54657931,2448.857146 900 | 2.153722831,50.38376778,2216.204284 901 | 2.436165002,58.13743269,2407.286008 902 | 2.260276597,59.76097238,2365.05488 903 | 2.226735047,53.92317349,2243.020143 904 | 2.223555886,61.20900519,2413.405436 905 | 2.277362034,48.05239186,2327.118323 906 | 2.515491714,56.37156228,2459.594821 907 | 2.231591254,52.22823712,2251.008179 908 | 2.363503947,53.75737859,2372.607567 909 | 2.238497577,50.13480893,2202.78846 910 | 2.136525879,59.92960062,2281.937307 911 | 2.004483901,61.46176254,2297.7046 912 | 2.105029913,55.67970958,2260.624767 913 | 2.275097277,55.76692426,2392.676408 914 | 2.208297517,61.09418383,2384.179176 915 | 2.275088386,69.34912808,2501.427597 916 | 2.370507948,55.88874159,2496.53316 917 | 1.914893978,56.8882964,2003.662905 918 | 2.237709683,64.43507354,2515.617516 919 | 2.008648994,60.6452049,2249.143193 920 | 2.274847315,60.54573091,2355.530545 921 | 2.717694357,47.21045102,2525.690522 922 | 1.953190182,56.14335675,2080.965218 923 | 2.03019553,49.39332474,2111.40646 924 | 2.114780319,54.75295264,2251.535894 925 | 2.075683586,55.18960541,2261.823407 926 | 2.118580185,47.28653992,2132.422606 927 | 2.083593049,57.19186986,2267.728149 928 | 2.414705881,63.6843222,2562.221602 929 | 2.012987514,52.38643359,2066.88301 930 | 2.342075884,54.8971472,2298.40842 931 | 2.152267368,52.78905848,2184.239973 932 | 2.280004565,62.20720827,2407.651574 933 | 2.359131297,58.38356606,2425.346848 934 | 2.158017102,55.38812486,2320.10946 935 | 2.336074187,60.38485622,2493.524016 936 | 2.03904827,57.03407583,2170.111976 937 | 2.056312376,61.00912913,2257.475721 938 | 2.549962994,56.33255888,2501.091265 939 | 2.544971113,60.35532264,2629.144318 940 | 2.397617891,52.57133959,2393.6995 941 | 2.647340685,62.9026545,2759.794164 942 | 2.223084266,52.600729,2303.949594 943 | 2.382675945,52.45534793,2488.765356 944 | 1.925090936,59.86557508,2138.845178 945 | 1.747024305,58.05627914,1991.212551 946 | 2.292148182,51.72476286,2291.2935 947 | 2.608824603,53.13936061,2536.891206 948 | 2.097135938,54.64775341,2270.299791 949 | 2.648733632,51.64355259,2626.603566 950 | 2.416879206,61.1986722,2568.983069 951 | 2.445709056,54.52668912,2477.600217 952 | 2.06889631,58.16528714,2238.115791 953 | 2.177616247,51.91413929,2217.463777 954 | 2.280081317,54.77217469,2328.660552 955 | 2.210951553,61.37856457,2382.124246 956 | 2.656899047,57.63198962,2683.591162 957 | 2.166261959,61.84313722,2292.435485 958 | 2.17722559,55.35685606,2269.050696 959 | 2.347453507,56.40898909,2436.035353 960 | 1.789873187,62.63646983,2012.319387 961 | 2.149252121,55.73141739,2280.042398 962 | 1.908838152,64.07911541,2244.844913 963 | 2.31568533,58.33219464,2397.910751 964 | 2.279557435,56.39436143,2457.089375 965 | 2.296955281,67.43056085,2593.225146 966 | 2.17792756,52.04833766,2175.357361 967 | 2.188355767,60.845993,2404.984701 968 | 2.434014523,56.51243838,2474.302139 969 | 2.480717306,64.67854601,2567.280465 970 | 2.334237516,60.87265779,2492.335968 971 | 2.056016697,47.91353901,2096.998302 972 | 2.289291258,60.03299313,2355.225478 973 | 2.09703388,58.16663777,2234.581817 974 | 2.384734134,57.73295368,2582.27948 975 | 2.403348148,51.95338945,2381.789544 976 | 2.165565035,62.62315891,2467.307182 977 | 2.05926956,59.01009038,2300.848035 978 | 2.46488364,56.58808128,2562.764485 979 | 2.186663214,55.27693605,2224.040699 980 | 2.04399899,51.35432872,2131.219474 981 | 1.971307623,53.13122237,2031.346274 982 | 2.131514623,50.96812444,2245.59405 983 | 1.942980688,57.04593254,2120.948889 984 | 2.436750441,61.18556452,2508.751044 985 | 1.99273054,65.10406704,2269.322372 986 | 1.990452219,52.51102279,2085.534307 987 | 2.38459603,57.74013178,2497.913238 988 | 2.327413919,56.9363765,2405.684511 989 | 2.816497184,45.03986697,2718.811585 990 | 2.134476489,68.01064417,2533.151582 991 | 2.171113726,61.92005319,2378.392345 992 | 2.018199743,56.92961587,2206.94618 993 | 1.936747824,52.96752441,2086.159182 994 | 2.59152853,57.28103007,2686.211789 995 | 1.740441475,55.09864486,1922.893274 996 | 1.868835087,60.54337734,2065.424594 997 | 2.528420416,52.39082811,2578.699184 998 | 2.643570716,54.62620358,2573.865933 999 | 2.009643674,57.00435706,2004.911218 1000 | 2.201655964,62.44779038,2344.098981 1001 | 2.180637971,46.29703432,2156.133786 1002 | -------------------------------------------------------------------------------- /bank_client_information.csv: -------------------------------------------------------------------------------- 1 | First Name,Last Name,Email,Postal Code,Net Worth 2 | Joseph,Patton,daafeja@boh.jm,M6U 5U7,"$2,629.13 " 3 | Noah,Moran,guutodi@bigwoc.kw,K2D 4M9,"$8,626.96 " 4 | Nina,Keller,azikez@gahew.mr,S1T 4E6,"$9,072.02 " 5 | -------------------------------------------------------------------------------- /fruits_input.txt: -------------------------------------------------------------------------------- 1 | Acai 2 | Apple 3 | Akee 4 | Apricot 5 | Avocado 6 | Banana 7 | Bilberry 8 | Blackberry 9 | Blackcurrant 10 | Black sapote 11 | Blueberry 12 | Boysenberry 13 | Buddha's hand (fingered citron) 14 | Crab apples 15 | Currant 16 | Cherry 17 | Cherimoya (Custard Apple) 18 | Chico fruit 19 | Cloudberry 20 | Coconut 21 | Cranberry 22 | Cucumber 23 | Damson 24 | Date 25 | Dragonfruit (or Pitaya) 26 | Durian 27 | Elderberry 28 | Feijoa 29 | Fig 30 | Goji berry 31 | Gooseberry 32 | Grape 33 | Raisin 34 | Grapefruit 35 | Guava 36 | Honeyberry 37 | Huckleberry 38 | Jabuticaba 39 | Jackfruit 40 | Jambul 41 | Japanese plum 42 | Jostaberry 43 | Jujube 44 | Juniper berry 45 | Kiwano (horned melon) 46 | Kiwifruit 47 | Kumquat 48 | Lemon 49 | Lime 50 | Loquat 51 | Longan 52 | Lychee 53 | Mango 54 | Mangosteen 55 | Marionberry 56 | Melon 57 | Cantaloupe 58 | Honeydew 59 | Watermelon 60 | Miracle fruit 61 | Mulberry 62 | Nectarine 63 | Nance 64 | Olive 65 | Orange 66 | Blood orange 67 | Clementine 68 | Mandarine 69 | Tangerine 70 | Papaya 71 | Passionfruit 72 | Peach 73 | Pear 74 | Persimmon 75 | Plantain 76 | Plum 77 | Prune (dried plum) 78 | Pineapple 79 | Pineberry 80 | Plumcot (or Pluot) 81 | Pomegranate 82 | Pomelo 83 | Purple mangosteen 84 | Quince 85 | Raspberry 86 | Salmonberry 87 | Rambutan (or Mamin Chino) 88 | Redcurrant 89 | Salal berry 90 | Salak 91 | Satsuma 92 | Soursop 93 | Star apple 94 | Star fruit 95 | Strawberry 96 | Surinam cherry 97 | Tamarillo 98 | Tamarind 99 | Ugli fruit 100 | White currant 101 | White sapote 102 | Yuzu 103 | 104 | -------------------------------------------------------------------------------- /sample_csv_file.csv: -------------------------------------------------------------------------------- 1 | first, last, email, postal, gender, dollar 2 | Joseph,Patton,daafeja@boh.jm,M6U 5U7,Male,"$2,629.13 " 3 | Noah,Moran,guutodi@bigwoc.kw,K2D 4M9,Male,"$8,626.96 " 4 | Nina,Keller,azikez@gahew.mr,S1T 4E6,Male,"$9,072.02 " 5 | -------------------------------------------------------------------------------- /sample_text_file.txt: -------------------------------------------------------------------------------- 1 | I am learning python now! 2 | It is super fun to learn Python programming 3 | I am learning how to handle files in python! --------------------------------------------------------------------------------