Add initial version of chapter 02's summary
This commit is contained in:
parent
9179521763
commit
54e63991a1
2 changed files with 102 additions and 0 deletions
|
@ -67,6 +67,7 @@ Alternatively, the content can be viewed in a web browser
|
|||
(Standard Library: `math` & `random` Modules;
|
||||
Third-party Packages: `numpy` Library;
|
||||
Writing one's own Modules)
|
||||
- [summary <img height="12" style="display: inline-block" src="static/link/to_nb.png">](https://nbviewer.jupyter.org/github/webartifex/intro-to-python/blob/develop/chapter_02_functions/03_summary.ipynb)
|
||||
|
||||
|
||||
#### Videos
|
||||
|
|
101
chapter_02_functions/03_summary.ipynb
Normal file
101
chapter_02_functions/03_summary.ipynb
Normal file
|
@ -0,0 +1,101 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "slide"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"# Chapter 2: Functions & Modularization"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "skip"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"## TL;DR"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "skip"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"A user-defined **function** is a **named sequence** of statements that perform a computation.\n",
|
||||
"\n",
|
||||
"Functions provide benefits as they\n",
|
||||
"\n",
|
||||
"- make programs easier to comprehend and debug for humans as they give names to the smaller parts of a larger program (i.e., they **modularize** a code base), and\n",
|
||||
"- eliminate redundancies by allowing **reuse of code**.\n",
|
||||
"\n",
|
||||
"Functions are **defined** once with the `def` statement. Then, they may be **called** many times with the call operator `()`.\n",
|
||||
"\n",
|
||||
"They may process **parameterized** inputs, **passed** in as **arguments**, and output a **return value**.\n",
|
||||
"\n",
|
||||
"Arguments may be passed in by **position** or **keyword**. Some functions may even require **keyword-only** arguments.\n",
|
||||
"\n",
|
||||
"**Lambda expressions** create anonymous functions.\n",
|
||||
"\n",
|
||||
"Functions are a special kind of **callables**. Any object that may be **called** with the call operator `()` is a callable. Built-in functions and **constructors** are other kinds of callables.\n",
|
||||
"\n",
|
||||
"Core Python can be extended with code from either the **standard library** or **third-party** libraries.\n",
|
||||
"\n",
|
||||
"Outside Jupyter notebooks, Python code is put into **modules** that are grouped in **packages**."
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.6"
|
||||
},
|
||||
"livereveal": {
|
||||
"auto_select": "code",
|
||||
"auto_select_fragment": true,
|
||||
"scroll": true,
|
||||
"theme": "serif"
|
||||
},
|
||||
"toc": {
|
||||
"base_numbering": 1,
|
||||
"nav_menu": {},
|
||||
"number_sections": false,
|
||||
"sideBar": true,
|
||||
"skip_h1_title": true,
|
||||
"title_cell": "Table of Contents",
|
||||
"title_sidebar": "Contents",
|
||||
"toc_cell": false,
|
||||
"toc_position": {
|
||||
"height": "calc(100% - 180px)",
|
||||
"left": "10px",
|
||||
"top": "150px",
|
||||
"width": "384px"
|
||||
},
|
||||
"toc_section_display": false,
|
||||
"toc_window_display": false
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
Loading…
Reference in a new issue