{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "# Python Functions"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "Functions are used everywhere and are very useful.\n",
    "- Reusing code blocks\n",
    "- Organizing code\n",
    "- Many libraries provide and require functions\n",
    "\n",
    "**Think of a function ```f(x)``` like a machine:**\n",
    "1. You put something in: ```x```\n",
    "2. You operate on ```x``` inside the function\n",
    "3. The function returns some result ```f(x)```.\n",
    "\n",
    "<img src=http://ignite.byu.edu/cbe263/lectures/L09f01.png width=300>\n",
    "\n",
    "        "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "**Keywords**\n",
    "- ```def```\n",
    "- ```return```\n",
    "- ```:```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "fragment"
    },
    "tags": []
   },
   "source": [
    "**Format**\n",
    "\n",
    "```python\n",
    "def myFuncName(var_1, var_2, others):\n",
    "    # Insert any python code here\n",
    "    # You can create new variables, they can use var_1, var_2, etc.\n",
    "    # You can print things, load data from files, make plots, etc.\n",
    "    \n",
    "    return XYZ       # Often a function returns a value\n",
    "                     # This is not required though\n",
    "                     # XYZ can be be an expression, a variable you defined, etc.\n",
    "```\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "\n",
    "Then we call the function like so:\n",
    "\n",
    "```python\n",
    "myValue = myFuncName(5.5,8.8, etc)\n",
    "```\n",
    "\n",
    "Or define variables and use them in calling the function\n",
    "\n",
    "```python\n",
    "x = 5.5\n",
    "y = 8.8\n",
    "\n",
    "z = myFuncName(x, y)\n",
    "```\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "\n",
    "Or use the function where a value is wanted:\n",
    "\n",
    "```python\n",
    "radius = 3\n",
    "cylinder_volume = circle_area(radius)*height\n",
    "```\n",
    "\n",
    "Or:\n",
    "```python\n",
    "print(\"cylinder volume =\", height*circle_area(radius))\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "### Practice\n",
    "\n",
    "- Write a function called ```my_sum``` that takes two numbers as arguments and returns The sum.\n",
    "- Then call the function and store it as a variable.\n",
    "- Then print the result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "fragment"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def my_sum(a, b):\n",
    "    return a + b\n",
    "\n",
    "s = my_sum(5, 6)\n",
    "\n",
    "print(\"the sum is\", s)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "### Examples\n",
    "- Compare the various versions of sum functions below"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "fragment"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def sum_1(x,y):      \n",
    "    z = x + y       \n",
    "    return z       \n",
    "\n",
    "my_sum = sum_1(5,6)\n",
    "\n",
    "print(\"The sum of 5 and 6 is\", my_sum)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def sum_2(x,y):\n",
    "    print(\"The sum of\", x, \"and\", y, \"is\", x+y)  \n",
    "\n",
    "print(sum_2(5,6))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def sum_3(x,y):\n",
    "    z = x+y\n",
    "    return z\n",
    "    print(\"This will not print: it's after the return\")\n",
    "          \n",
    "print( sum_3(5,6) )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "fragment"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def sum_4(x,y):\n",
    "    the_sum = x+y\n",
    "    return the_sum\n",
    "\n",
    "a = 6\n",
    "b = 7\n",
    "c = sum_4(a, b)\n",
    "\n",
    "print(\"The sum of\", a, \"and\", b, \"is\", c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def add_and_multiply(x,y):\n",
    "    return x+y, x*y     \n",
    "\n",
    "sp = add_and_multiply(5,6)\n",
    "print(sp[0], sp[1])\n",
    "\n",
    "s, p = add_and_multiply(5,6)\n",
    "print(s, p)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "### Key points\n",
    "- Remember the ```def``` and the ```:``` and the ```return```\n",
    "- Return statements are optional, depending on what you want to do.\n",
    "- We can call functions with arguments as values, like ```sum_3(5,6)```.\n",
    "- We can create variables to hold values, then pass those variables as function arguments, like \n",
    "    ```\n",
    "    x=5\n",
    "    y=7 \n",
    "    z = sum_5(x,y)\n",
    "    ```\n",
    "- The names of variables in the function argument list are independent of the variable names you pass to the function.\n",
    "    - If I write $f(x) = x^2$, it is fine to write $f(5)$.\n",
    "        - The function will take $x$ to be 5, then compute $5^2$.\n",
    "    - If I write $f(x) = x^2$, it is fine to write $a=3$, $f(a)$.\n",
    "        - The function will take $x$ to be $a$, then will compute $a^2$.\n",
    "        - Since $a=3$, the result will be $3^2$.\n",
    "- If the function returns a value, we can use it wherever a value is expected\n",
    "    - As in ```z = sum_3(x,y)```\n",
    "    - Or this ```print(sum_3(x,y))```\n",
    "        "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "### Practice\n",
    "- Write a function called ```ft_to_m``` that will take a length in feet and convert it to a length in meters.\n",
    "- Use the converstion 1 m = 3.28084 ft."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "fragment"
    },
    "tags": []
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "### Practice\n",
    "\n",
    "- Write a function called ```P_IG``` that takes the number of moles, temperature, and volume as aguments, and returns the ideal gas pressure.\n",
    "- Try out the function.\n",
    "- Don't forget to comment your code, including comments.\n",
    "- Use good variable names."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "fragment"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def P_IG(n, T, V):\n",
    "    '''\n",
    "    n is moles in kmol\n",
    "    T is temperature in K\n",
    "    V is volume in m3\n",
    "    '''\n",
    "    \n",
    "    Rgas = 8314.46      # J/kmol*K\n",
    "    return n*Rgas*T/V      # Pa\n",
    "\n",
    "P_IG(1, 300, 10)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "### Docstrings: documentation\n",
    "\n",
    "A triple quoted string at the beginning of the function is a docstring that is output when getting \"help\" on the function."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "fragment"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def square_it(x):\n",
    "    \"\"\"\n",
    "    input:   x \n",
    "    return:  x**2\n",
    "    type \"help(square_it)\" to see these comments.\n",
    "    \"\"\"\n",
    "    \n",
    "    return x*x\n",
    "\n",
    "\n",
    "help(square_it)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "### Functions can have default arguments"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "fragment"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def get_force(m, g=9.81) : # if not given, g defaults to 9.81\n",
    "    print(\"g = \", g)\n",
    "    return m*g\n",
    "\n",
    "print( get_force(10) )     # no \"g\" --> g=9.81\n",
    "print()\n",
    "print( get_force(20,2) )   # g = 2, not 9.81\n",
    "print()\n",
    "print( get_force(g=4, m=20) ) # can be explicit about it"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "### Practice\n",
    "- Rewrite your ```P_IG``` function above to use a default value for ```Rg```."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "fragment"
    },
    "tags": []
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "**Type ```help(print)``` and see the default arguments.**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "fragment"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "print(1,2,3, sep=\"\\n\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "### Function arguments can be specified out of order if we are explicit about the names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "fragment"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def myfunc(a,b) :\n",
    "    print(\"a = \", a)\n",
    "    print(\"b = \", b)\n",
    "\n",
    "myfunc(b=7,a=5)            # note, calling with the opposite argument order"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "### Functions can be passed as arguments to other functions\n",
    "\n",
    "**Example**\n",
    "- For given $x_1$, and $x_2$, compute $S = f(x_1)+f(x_2)$ for any function $f$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "#-------------- Define the sum function\n",
    "\n",
    "def sum_func(f, x1, x2):\n",
    "    return f(x1) + f(x2)\n",
    "\n",
    "#-------------- Define the functions to be summed\n",
    "\n",
    "def f_a(x):\n",
    "    return 2*x\n",
    "def f_b(x):\n",
    "    return x**0.5\n",
    "\n",
    "import numpy as np\n",
    "\n",
    "#-------------- Define the values of x and call sum_func\n",
    "\n",
    "x1 = 4\n",
    "x2 = 9\n",
    "\n",
    "print(  sum_func(f_a, x1, x2)  )\n",
    "print(  sum_func(f_b, x1, x2)  )\n",
    "print(  sum_func(np.sin, x1, x2)  )"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "### Practice\n",
    "\n",
    "- Write a function that computes the following integral for *any* function $f(x)$\n",
    "$$I = \\int_a^bf(x)dx$$\n",
    "- Evaluate the integral using the areas of two trapazoids.\n",
    "\n",
    "<img src=http://ignite.byu.edu/cbe263/lectures/L09f02.png width=200>\n",
    "\n",
    "- Find a midpoint $m=(a+b)/2$.\n",
    "  \n",
    "$$I = \\underbrace{(m-a)\\frac{f(a)+f(m)}{2}}_{\\text{trapazoid 1}} + \n",
    "      \\underbrace{(b-m)\\frac{f(m)+f(b)}{2}}_{\\text{trapazoid 2}}$$\n",
    "\n",
    "- Try this on $I = \\int_1^2x^2dx = 2.33333$\n",
    "- **Question**: what is the structure?\n",
    "    - How many functions do you need to define?\n",
    "    - How to call the function?\n",
    "    - What order to define things in.\n",
    "    - After you have thought about this, look at the previous example and consider it's structure."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def integrate_f(f, a, b) :\n",
    "    m = 0.5*(a + b)\n",
    "    return (m-a)*(f(a) + f(m))/2   +   (b-m)*(f(m) + f(b))/2\n",
    "\n",
    "#---------- define a couple functions\n",
    "\n",
    "def f_xSquared(x) :\n",
    "    return x**2.0\n",
    "\n",
    "#----------- integrate the function\n",
    "\n",
    "a = 1\n",
    "b = 2\n",
    "\n",
    "I = integrate_f( f_xSquared, a, b )\n",
    "\n",
    "print(\"I       =\", I)\n",
    "print(\"I_exact =\", 2**3/3 - 1/3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "### Scope: global, local\n",
    "\n",
    "- Variables or functions defined inside a function are **local** to that function and cannot be seen outside of it.\n",
    "- Variables or functions defined outside a function are **global** and can be seen inside later functions."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "fragment"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "a = 5.5                 # a has global scope\n",
    "\n",
    "def ff():\n",
    "    print(\"a = \", a)    # a isn't passed in, but is known\n",
    "\n",
    "ff()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "a = 1.1\n",
    "\n",
    "def ff2():\n",
    "    a = 2.2     # this is a NEW local a, not the same as above\n",
    "    print(\"inside:  a = \", a)\n",
    "\n",
    "ff2()\n",
    "print(\"outside: a = \", a)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "### Note\n",
    "- Often you are given problems with many known parameters.\n",
    "- It is normally best to put the parameters inside the function, rather than outside the function.\n",
    "- This lets the function *stand alone*.\n",
    "- (There may be reasonable exceptions to this rule though.)\n",
    "\n",
    "Previously we used the following vapor pressure equation, with values of A, B, C given for Benzene.\n",
    "$$P_i^{sat}(T) = \\exp\\left(A_i - \\frac{B_i}{T+C_i}\\right)$$.\n",
    "- A = 13.7819\n",
    "- B = 2726.81\n",
    "- C = 217.572\n",
    "\n",
    "Code this function."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "\n",
    "#---------- DO THIS\n",
    "\n",
    "def Psat_B(T):\n",
    "    A = 13.7819\n",
    "    B = 2726.81\n",
    "    C = 217.572\n",
    "    return np.exp(A - B/(T+C))\n",
    "\n",
    "#---------- NOT THIS\n",
    "\n",
    "A = 13.7819\n",
    "B = 2726.81\n",
    "C = 217.572\n",
    "\n",
    "def Psat_B(T):\n",
    "    return np.exp(A - B/(T+C))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "### A function must be defined before it is *USED*\n",
    "\n",
    "* If you write some code that uses functions that are not defined until later, it won't work, because python doesn't know about the functions yet.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "fragment"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "30.25\n"
     ]
    }
   ],
   "source": [
    "a = 5.5\n",
    "print(f_below(a))   # function that is not defined yet!\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "\n",
    "def f_below(x):\n",
    "    return x*x"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "**But note that the following works just fine.**\n",
    "- function ```a``` uses function ```b```, but ```b``` is defined below ```a```\n",
    "- But this works because both ```a``` and ```b``` are defined when ```a``` is actually **called**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "fragment"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def a(x):\n",
    "    return b(x)\n",
    "\n",
    "def b(x):\n",
    "    return x**2\n",
    "\n",
    "print( a(3) )"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "**Similarly, consider this example**\n",
    "- The function uses ```g```, which is not defined until after the function is defined.\n",
    "- Will this work?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "fragment"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "def fma(m):\n",
    "    return m*g\n",
    "\n",
    "g = 9.81\n",
    "\n",
    "F = fma(100)\n",
    "\n",
    "print(F)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "fragment"
    },
    "tags": []
   },
   "source": [
    "- This works because g is defined when the function is **called**, that is, it is defined at the time it is **needed**."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": "slide"
    },
    "tags": []
   },
   "source": [
    "### See also:\n",
    "- [Built-in Python functions](https://docs.python.org/2/library/functions.html)\n",
    "    - There are tons of other functions available through Python libraries, like numpy\n",
    "- [anonymous (lambda) functions](https://www.w3schools.com/python/python_lambda.asp)\n",
    "- [\\*args and \\*\\*kwargs](https://www.digitalocean.com/community/tutorials/how-to-use-args-and-kwargs-in-python-3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function print in module builtins:\n",
      "\n",
      "print(*args, sep=' ', end='\\n', file=None, flush=False)\n",
      "    Prints the values to a stream, or to sys.stdout by default.\n",
      "\n",
      "    sep\n",
      "      string inserted between values, default a space.\n",
      "    end\n",
      "      string appended after the last value, default a newline.\n",
      "    file\n",
      "      a file-like object (stream); defaults to the current sys.stdout.\n",
      "    flush\n",
      "      whether to forcibly flush the stream.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(print)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5 kittens 6\n"
     ]
    }
   ],
   "source": [
    "a = 5\n",
    "b = 6\n",
    "\n",
    "print(a,b, sep = ' kittens ')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": true,
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "celltoolbar": "Slideshow",
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.14.7"
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
