|
565 | 565 | "cell_type": "markdown",
|
566 | 566 | "metadata": {},
|
567 | 567 | "source": [
|
568 |
| - "## Summary" |
| 568 | + "## Anatomy of a Function" |
569 | 569 | ]
|
570 | 570 | },
|
571 | 571 | {
|
572 | 572 | "cell_type": "markdown",
|
573 | 573 | "metadata": {},
|
574 | 574 | "source": [
|
575 |
| - "You now know **how to write your own functions!**\n", |
| 575 | + "This notebook has introduced a number of terms that are specific to functions!\n", |
| 576 | + "\n", |
| 577 | + "To review some of these terms, we start by first creating code that defines and uses a very simple function:" |
| 578 | + ] |
| 579 | + }, |
| 580 | + { |
| 581 | + "cell_type": "code", |
| 582 | + "execution_count": null, |
| 583 | + "metadata": {}, |
| 584 | + "outputs": [], |
| 585 | + "source": [ |
| 586 | + "def add(a, b):\n", |
| 587 | + " total = a + b\n", |
| 588 | + " return total\n", |
| 589 | + "\n", |
| 590 | + "val0 = 23\n", |
| 591 | + "val1 = 4\n", |
| 592 | + "\n", |
| 593 | + "result = add(val0, val1)\n", |
576 | 594 | "\n",
|
| 595 | + "print(\"The sum is: \" + str(result))" |
| 596 | + ] |
| 597 | + }, |
| 598 | + { |
| 599 | + "cell_type": "markdown", |
| 600 | + "metadata": {}, |
| 601 | + "source": [ |
| 602 | + "The following image visually identifies some of the function-specific terms related to the above code:\n", |
| 603 | + "\n", |
| 604 | + "" |
| 605 | + ] |
| 606 | + }, |
| 607 | + { |
| 608 | + "cell_type": "markdown", |
| 609 | + "metadata": {}, |
| 610 | + "source": [ |
| 611 | + "***" |
| 612 | + ] |
| 613 | + }, |
| 614 | + { |
| 615 | + "cell_type": "markdown", |
| 616 | + "metadata": {}, |
| 617 | + "source": [ |
| 618 | + "## Summary" |
| 619 | + ] |
| 620 | + }, |
| 621 | + { |
| 622 | + "cell_type": "markdown", |
| 623 | + "metadata": {}, |
| 624 | + "source": [ |
| 625 | + "You now know **how to write your own functions!**" |
| 626 | + ] |
| 627 | + }, |
| 628 | + { |
| 629 | + "cell_type": "markdown", |
| 630 | + "metadata": {}, |
| 631 | + "source": [ |
577 | 632 | "The combined mechanism to pass variables to a function (using [parameters](#Adding-Parameters-to-a-Function)) and to [return a value](http://localhost:8888/notebooks/python_basics/005_Write_Your_Own_Functions.ipynb#Returning-value-of-a-function) after its execution is a powerful mechanism to reduce code repetition and to better organize your programs. \n",
|
578 | 633 | "\n",
|
579 | 634 | "We will end this notebook with an exercise that will give you a bit of more freedom on how to implement the code. Feel free to experiment with some of the notions that you have just learned. The provided solution is just one of the possible way to achieve the task!"
|
|
657 | 712 | "source": [
|
658 | 713 | "* [The official Python 3.6 documentation](https://docs.python.org/3.6/index.html)\n",
|
659 | 714 | " * [Built-in functions](https://docs.python.org/3.6/library/functions.html)\n",
|
660 |
| - " * [None](https://docs.python.org/3.6/c-api/none.html?highlight=none#the-none-object)" |
| 715 | + " * [None](https://docs.python.org/3.6/c-api/none.html?highlight=none#the-none-object)\n", |
| 716 | + "* [Flattening](https://en.wikipedia.org/wiki/Flattening)" |
661 | 717 | ]
|
662 | 718 | },
|
663 | 719 | {
|
|
0 commit comments