Skip to content

Commit 00c6b4c

Browse files
author
giumas
committed
added terminology figure to 005
1 parent cb6b6f1 commit 00c6b4c

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

005_Write_Your_Own_Functions.ipynb

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,15 +565,70 @@
565565
"cell_type": "markdown",
566566
"metadata": {},
567567
"source": [
568-
"## Summary"
568+
"## Anatomy of a Function"
569569
]
570570
},
571571
{
572572
"cell_type": "markdown",
573573
"metadata": {},
574574
"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",
576594
"\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+
"![Function Terminology](images/005_500_function_terminology.png)"
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": [
577632
"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",
578633
"\n",
579634
"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,7 +712,8 @@
657712
"source": [
658713
"* [The official Python 3.6 documentation](https://docs.python.org/3.6/index.html)\n",
659714
" * [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)"
661717
]
662718
},
663719
{
93.6 KB
Loading

images/resources/resources.pptx

8.73 KB
Binary file not shown.

0 commit comments

Comments
 (0)