{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chapter 2: Functions & Modularization" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Content Review" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Essay Questions " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Answer the following questions *briefly*!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Q1**: What behavior of the `def` statement makes it a **statement**? Is there a way to use an **expression** to create a function?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**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**?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Q3**: What does it mean for a variable to go out of **scope**?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Q4**: How can a **global** variable be **shadowed**? Is this good or bad?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Q5**: Explain the concept of **forwarding** a **function call**." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Q6**: What are **keyword-only arguments** and when is it appropriate to use them?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Q7**: What are **callables**? How do they relate to `function` objects?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "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": [ "**Q8**: A mere function **call** is just an **expression**." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Q9**: When using the `import` statement, we need to ensure that the imported attributes do *not* overwrite any already defined variables and functions." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Q10:** Functions always have a name by which we can call them." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**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." ] }, { "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", "version": "3.7.4" }, "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, "nbformat_minor": 4 }