2019-10-15 20:07:57 +02:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
2020-01-28 10:48:37 +01:00
"# Chapter 2: Functions & Modularization"
2019-10-15 20:07:57 +02:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Content Review"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2020-02-02 16:31:31 +01:00
"Read [Chapter 2](https://nbviewer.jupyter.org/github/webartifex/intro-to-python/blob/master/02_functions_00_lecture.ipynb) of the book. Then, work through the questions below."
2019-10-15 20:07:57 +02:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Essay Questions "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2020-01-28 10:48:37 +01:00
"Answer the following questions *briefly*!"
2019-10-15 20:07:57 +02:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2020-01-28 10:48:37 +01:00
"**Q1**: What behavior of the `def` statement makes it a **statement**? Is there a way to use an **expression** to create a function?"
2019-10-15 20:07:57 +02:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2020-01-28 10:48:37 +01:00
"**Q2**: One of the first confusions of experienced programmers coming from other languages to Python regards the observation that **\"everything in Python is an object\"** (cf., this [discussion](https://www.reddit.com/r/learnpython/comments/8rypx9/everything_in_python_is_an_object/)). How does this relate to **functions**?"
2019-10-15 20:07:57 +02:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2020-02-05 18:31:52 +01:00
"**Q3**: What does it mean for a variable to go out of **scope**?"
2019-10-15 20:07:57 +02:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2020-01-28 10:48:37 +01:00
"**Q4**: How can a **global** variable be **shadowed**? Is this good or bad?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2020-02-05 18:31:52 +01:00
"**Q5**: Explain the concept of **forwarding** a **function call**."
2020-01-28 10:48:37 +01:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Q6**: What are **keyword-only arguments** and when is it appropriate to use them?"
2019-10-15 20:07:57 +02:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" "
]
},
2020-02-05 18:31:52 +01:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Q7**: What are **callables**? How do they relate to `function` objects?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" "
]
},
2019-10-15 20:07:57 +02:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### True / False Questions"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Motivate your answer with *one short* sentence!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2020-02-05 18:31:52 +01:00
"**Q8**: A mere function **call** is just an **expression**."
2019-10-15 20:07:57 +02:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2020-02-05 18:31:52 +01:00
"**Q9**: When using the `import` statement, we need to ensure that the imported attributes do *not* overwrite any already defined variables and functions."
2019-10-15 20:07:57 +02:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2020-02-05 18:31:52 +01:00
"**Q10:** Functions always have a name by which we can call them."
2019-10-15 20:07:57 +02:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2020-02-05 18:31:52 +01:00
"**Q11**: The [standard library](https://docs.python.org/3/library/index.html) is a collection of numerical tools often used in scientific computing, for example, advanced mathematical functions or utilities for simulation."
2019-10-15 20:07:57 +02:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" "
]
}
],
"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",
2020-01-28 10:48:37 +01:00
"version": "3.7.4"
2019-10-15 20:07:57 +02:00
},
"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": {},
"toc_section_display": false,
"toc_window_display": false
}
},
"nbformat": 4,
2020-01-28 10:48:37 +01:00
"nbformat_minor": 4
2019-10-15 20:07:57 +02:00
}