From 42ed0e5518ad35f2645a6b6a4e8b897855c3f8e4 Mon Sep 17 00:00:00 2001 From: "Kenneth C. Kleissl" Date: Fri, 10 Jan 2020 11:37:52 +0100 Subject: [PATCH] fix of invalid notebook --- .../Session 2 - Data Structures.ipynb | 2 +- .../Session 3 - Functions.ipynb | 369 +----------------- .../Session 4 - Plotting.ipynb | 2 +- 3 files changed, 15 insertions(+), 358 deletions(-) diff --git a/Session 2 - Data Structures/Session 2 - Data Structures.ipynb b/Session 2 - Data Structures/Session 2 - Data Structures.ipynb index 4cd910f..fe0a013 100644 --- a/Session 2 - Data Structures/Session 2 - Data Structures.ipynb +++ b/Session 2 - Data Structures/Session 2 - Data Structures.ipynb @@ -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, diff --git a/Session 3 - Functions/Session 3 - Functions.ipynb b/Session 3 - Functions/Session 3 - Functions.ipynb index ff7a56c..e0675c2 100644 --- a/Session 3 - Functions/Session 3 - Functions.ipynb +++ b/Session 3 - Functions/Session 3 - Functions.ipynb @@ -1,337 +1,5 @@ { "cells": [ - { - "cell_type": "markdown", - "metadata": { - "cell_style": "center" - }, - "source": [ - "\n", - "# 3. Functions\n", - "A **function** is a block of code that is first defined, and thereafter can be called to run as many times as needed. A function might have arguments, some of which can be optional if a default value is specified.\n", - "\n", - "A function is called by parentheses: `function_name()`. Arguments are placed inside the parentehes and comma separated if there are more than one.\n", - "Similar to `f(x, y)` from mathematics.\n", - "\n", - "A function can return one or more values to the caller. The values to return are put in the `return` statement. When the code hits a `return` statement the function terminates. If no `return` statement is given, the function will return `None`.\n", - "\n", - "The general syntax of a function is:\n", - "\n", - "~~~python\n", - "def function_name(arg1, arg2, default_arg1=0, default_arg2=None):\n", - " '''This is the docstring \n", - " \n", - " The docstring explains what the function does, so it is like a multiline comment. It does not have to be here, \n", - " but it is good practice to use them to document the code. They are especially useful for more complicated \n", - " functions, although functions should in general be kept as simple as possible.\n", - " Arguments could be explained together with their types (e.g. strings, lists, dicts etc.).\n", - " '''\n", - " \n", - " # Function code goes here\n", - " \n", - " # Possible 'return' statement terminating the function. If 'return' is not specified, function returns None.\n", - " return return_val1, return_val2\n", - "~~~\n", - "\n", - "If multiple values are to be returned, they can be separated by commas as shown. The returned entity will by default be a `tuple`.\n", - "\n", - "Note that when using default arguments, it is good practice to only use immutable types. An example further below will demonstrate why this is recommended. \n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Basic functions\n", - "A simple function with one argument is defined below." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 1, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "from IPython.display import HTML\n", - "HTML(''.format(open('../css/cowi.css').read()))" - ] - }, { "cell_type": "markdown", "metadata": { @@ -400,7 +68,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -409,7 +77,7 @@ "36.25" ] }, - "execution_count": 2, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -427,7 +95,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -459,7 +127,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -494,18 +162,7 @@ }, { "cell_type": "markdown", - "execution_count": 1, "metadata": {}, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "invalid syntax (, line 3)", - "output_type": "error", - "traceback": [ - "\u001b[1;36m File \u001b[1;32m\"\"\u001b[1;36m, line \u001b[1;32m3\u001b[0m\n\u001b[1;33m The built-in `enumerate` is useful when you want to loop over an iterable together with the index of each of its elements:\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n" - ] - } - ], "source": [ "## Examples of built-in functions\n", "### Using `enumerate` for looping in index/value pairs\n", @@ -514,7 +171,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -540,7 +197,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -572,7 +229,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -610,7 +267,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -646,7 +303,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -676,7 +333,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -916,7 +573,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -1189,7 +846,7 @@ "" ] }, - "execution_count": 11, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -1217,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, diff --git a/Session 4 - Plotting/Session 4 - Plotting.ipynb b/Session 4 - Plotting/Session 4 - Plotting.ipynb index 137db26..1dea3cf 100644 --- a/Session 4 - Plotting/Session 4 - Plotting.ipynb +++ b/Session 4 - Plotting/Session 4 - Plotting.ipynb @@ -1106,7 +1106,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.4" + "version": "3.7.5" }, "latex_envs": { "LaTeX_envs_menu_present": true,