Merge branch 'master' of https://github.com/Python-Crash-Course/Python101
commit
d1c15f682a
|
@ -1701,7 +1701,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.7.4"
|
||||
"version": "3.7.5"
|
||||
},
|
||||
"latex_envs": {
|
||||
"LaTeX_envs_menu_present": true,
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
"source": [
|
||||
"* **Note 1:** Call to function `circle_area` defined in Exercise instead of defining the expression `pi * r**2 / 4` again. The concept of functions calling other functions can be used to make modular programs that are easy to follow and maintain. Each function only needs to do a small thing in itself.\n",
|
||||
"\n",
|
||||
"* **Note 2:** The input parameter when the function was *defined* was a list called `radii`, but the when the function was *called*, the input list was called `list_of_radii`. Thus, the input parameters passed into a function do not need to have the same name as when the function is defined."
|
||||
"* **Note 2:** The input parameter when the function was *defined* was a list called `radii`, but when the function was *called*, the input list was called `list_of_radii`. Thus, the input parameters passed into a function do not need to have the same name as when the function is defined."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -823,7 +823,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.7.4"
|
||||
"version": "3.7.5"
|
||||
},
|
||||
"latex_envs": {
|
||||
"LaTeX_envs_menu_present": true,
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
|
@ -68,7 +68,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -77,7 +77,7 @@
|
|||
"36.25"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
|
@ -95,7 +95,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -127,7 +127,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -162,17 +162,16 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"cell_style": "center"
|
||||
},
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Examples of built-in functions\n",
|
||||
"### Using `enumerate` for looping in index/value pairs\n",
|
||||
"The built-in `enumerate` is useful when you want to loop over an iterable together with the index of each of its elements:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -198,7 +197,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -230,7 +229,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -268,7 +267,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -304,7 +303,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -327,14 +326,14 @@
|
|||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"`zip` stops when the shortest iterable is exhausted. So if if `c` is removed from the first string in the example above, we have iterables of lengths 2, 3 and 3. \n",
|
||||
"`zip` stops when the shortest iterable is exhausted. So if `c` is removed from the first string in the example above, we have iterables of lengths 2, 3 and 3. \n",
|
||||
"\n",
|
||||
"Thus, only two iterations are performed:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -407,7 +406,7 @@
|
|||
" # Your code goes here\n",
|
||||
"~~~\n",
|
||||
"\n",
|
||||
"Try to call it to see if it works. If you want to access `pi` to avoid typing it out yourself, put the line `from math import pi` at some point before calling the `circle_area` function.\n"
|
||||
"Try to call it to see if it works. If you want to access `pi` to avoid typing it out yourself, put the line `from math import pi` at some point before defining the `circle_area` function.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -415,7 +414,7 @@
|
|||
"metadata": {},
|
||||
"source": [
|
||||
"# Exercise 2\n",
|
||||
"Write a function that takes a list `radii` as input and returns a list of the corresponding circle areas. Try to set it up from scratch and test it.\n",
|
||||
"Write a function that takes a list `radii` as input and returns a list of the corresponding circle areas. Try to set it up from scratch and test it (note that the build-in `map()` function does the same).\n",
|
||||
"\n",
|
||||
"You can use the function from the previous exercise if you want."
|
||||
]
|
||||
|
@ -574,7 +573,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -847,7 +846,7 @@
|
|||
"<IPython.core.display.HTML object>"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
|
@ -875,7 +874,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.7.4"
|
||||
"version": "3.7.5"
|
||||
},
|
||||
"latex_envs": {
|
||||
"LaTeX_envs_menu_present": true,
|
||||
|
|
|
@ -1105,7 +1105,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.7.4"
|
||||
"version": "3.7.5"
|
||||
},
|
||||
"latex_envs": {
|
||||
"LaTeX_envs_menu_present": true,
|
||||
|
|
Loading…
Reference in New Issue