{ "cells": [ { "cell_type": "markdown", "metadata": { "colab_type": "text", "id": "Nm10RzJa_a1X" }, "source": [ "# Python Basics\n", "* Wenchang Yang (wenchang@princeton.edu)\n", "* Department of Geosciences, Princeton University\n", "* Sep 30, 2019, Junior Colloquium" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Start Jupyter Notebook\n", "Run a Terminal (or iTerm), and in the Terminal type:\n", "\n", " jupyter notebook\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Using Jupyter Noteook\n", "\n", "You use Jupyter to create an iPython Notebook.\n", "\n", "The notebook contains a series of \"cells\".\n", "\n", "Each cell can be either Code (that is, Python) or Markdown (that is, fancy text). You can set the cell type from the menu on the tool bar.\n", "\n", "To execute a cell, that is, run it, select the cell and press Shift-Enter. Or select the cell and click the run button." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Python Comments" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# Comments are intended to help a person (including yourself) read your code.\n", "# Comments start with a \"#\".\n", "\n", "x = 1 # A comment can also follow a Python statement." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Indentation is part of Python Syntax" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Try to run the cell below:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "colab": {}, "colab_type": "code", "id": "JRyR_QqhK4NY" }, "outputs": [ { "ename": "IndentationError", "evalue": "unexpected indent (, line 3)", "output_type": "error", "traceback": [ "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m3\u001b[0m\n\u001b[0;31m b = 2\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mIndentationError\u001b[0m\u001b[0;31m:\u001b[0m unexpected indent\n" ] } ], "source": [ "# Indentation matters\n", "a = 1\n", " b = 2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Variables\n", "\n", "A variable is a named place in computer memory into which you put a\n", "value or values.\n", "\n", "You make up the name, preferably something meaningful. Start with a\n", "letter, then letters and/or numbers and underscore. Upper/lower case matters.\n", "\n", "Examples of variable names:\n", "\n", " filename1\n", " largestValue\n", " number_of_students\n", " i\n", " I" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Numbers" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The Python can act as a simple calculator: you type an expression at it and it will write the value. Expression syntax is straightforward: the operators `+`, `-`, `*` and `/` work just like in most other languages (for example, Pascal or C); parentheses (()) can be used for grouping. For example:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5.0" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(50 - 5*6) / 4" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With Python, it is possible to use the ** operator to calculate powers" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "128" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "2 ** 7 # 2 to the power of 7" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The equal sign (`=`) is used to assign a value to a variable:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "width = 20\n", "height = 5\n", "area = width * height" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can use the `print` function to show the result." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "100\n" ] } ], "source": [ "print(area)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Strings\n", "Besides numbers, Python can also manipulate strings, which can be expressed in several ways. They can be enclosed in single quotes (`'...'`) or double quotes (`\"...\"`) with the same result." ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "hellow world\n", "doesn't\n" ] } ], "source": [ "print('hellow world') # single quotes\n", "print(\"doesn't\") # ...or use double quotes instead" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Strings can be concatenated with `+`:" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Life is short, I use Python.'" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "'Life is short, ' + 'I use Python.'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Strings can be indexed (subscripted), with the first character having index **0**." ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'P'" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "word = 'Python'\n", "word[0] # character in position 0" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'n'" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "word[5] # character in position 5" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In addition to indexing, slicing is also supported. While indexing is used to obtain individual characters, slicing allows you to obtain substring:" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Py'" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "word[0:2] # characters from position 0 (included) to 2 (excluded)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that the start is always **included**, and the end always **excluded.**" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Lists\n", "A list is an ordered series of objects.\n", "\n", "Lists are indexed by integers, **starting from 0.**" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[1, 4, 9, 16, 25]\n" ] } ], "source": [ "# Here is a list of square numbers\n", "squares = [1, 4, 9, 16, 25]\n", "print(squares)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Like strings, lists can be indexed and sliced:" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "squares[0] # indexing returns the item" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[4, 9]" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "squares[1:3] # slicing returns a new list" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Lists also support operations like concatenation:" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "squares + [36, 49, 64, 81, 100]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Unlike strings, which are immutable, lists are a mutable type, i.e. it is possible to change their content:" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[1, 4, 9, 16, 25, 30]\n" ] } ], "source": [ "squares.append(30)\n", "print(squares)" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[1, 4, 9, 16, 25, 36]\n" ] } ], "source": [ "squares[5] = 36\n", "print(squares)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### `if` statements" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "a <= b\n" ] } ], "source": [ "a = 3\n", "b = 5\n", "if a > b:\n", " print('a > b')\n", "else:\n", " print('a <= b')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### `for` loops" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The syntax of a for loop is:\n", "\n", "```python\n", "for variable in iterable:\n", " do something\n", " ```" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1\n", "4\n", "9\n", "16\n", "25\n", "36\n" ] } ], "source": [ "for i in squares:\n", " print(i)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Tuples\n", "A tuple is like a list, but immutable (cannot be changed in place)." ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [], "source": [ "t = (2019, 'September', 'Monday')" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2019\n", "('September', 'Monday')\n" ] } ], "source": [ "print(t[0])\n", "print(t[1:3])" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "ename": "TypeError", "evalue": "'tuple' object does not support item assignment", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# Immutable\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mt\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"Can't do this\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;31mTypeError\u001b[0m: 'tuple' object does not support item assignment" ] } ], "source": [ "# Immutable\n", "t[0] = \"Can't do this\"" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "ename": "AttributeError", "evalue": "'tuple' object has no attribute 'append'", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Can't do this either\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;31mAttributeError\u001b[0m: 'tuple' object has no attribute 'append'" ] } ], "source": [ "t.append(\"Can't do this either\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Dictionaries\n", "- A dictionary is a collection of key/value pairs.\n", "- It is mutable (like a list)\n", "- A dictionary is unordered (not like a list)." ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'birthYear': 1746, 'color': 'Orange and Black', 'nickname': 'Tigers'}\n" ] } ], "source": [ "# In this example, the keys are 'birthYear', 'color' and 'nickname'\n", "# and the values are 1746, 'Orange and Black', and 'Tigers'\n", "\n", "pu = {'birthYear': 1746, 'color': 'Orange and Black', 'nickname': 'Tigers'}\n", "print(pu)" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Tigers\n" ] } ], "source": [ "# Values can be accessed by keys\n", "\n", "print(pu['nickname'])" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'birthYear': 1746, 'color': 'Orange and Black', 'nickname': 'Tigers', 'oldName': 'College of New Jersey'}\n" ] } ], "source": [ "# Mutable. Values can be modified or added.\n", "\n", "pu['oldName'] = 'College of New Jersey'\n", "print(pu)" ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "birthYear : 1746\n", "color : Orange and Black\n", "nickname : Tigers\n", "oldName : College of New Jersey\n" ] } ], "source": [ "# Iterating over a dictionary\n", "\n", "for k,v in pu.items():\n", " print(k, ':', v)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Functions\n", "A function is a block of code that you define for later use (potentially multiple times)." ] }, { "cell_type": "code", "execution_count": 58, "metadata": {}, "outputs": [], "source": [ "# define the function\n", "\n", "def hello_world():\n", " print('Hellow World!')" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Hellow World!\n" ] } ], "source": [ "# call the function\n", "\n", "hello_world()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Functions can return values." ] }, { "cell_type": "code", "execution_count": 60, "metadata": {}, "outputs": [], "source": [ "# Functions can return values\n", "\n", "def get_school_name():\n", " return 'Princeton University'" ] }, { "cell_type": "code", "execution_count": 61, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Princeton University\n" ] } ], "source": [ "print( get_school_name() )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Function arguments\n", "\n", "You can pass objects into a function as \"arguments\". There are two kinds of arguments: positional and keyword." ] }, { "cell_type": "code", "execution_count": 62, "metadata": {}, "outputs": [], "source": [ "def do_minus(a, b):\n", " return a - b" ] }, { "cell_type": "code", "execution_count": 66, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5" ] }, "execution_count": 66, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Positional arguments.\n", "\n", "do_minus(10, 5)" ] }, { "cell_type": "code", "execution_count": 68, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5" ] }, "execution_count": 68, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Keyword arguments.\n", "\n", "do_minus(b=5, a=10)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Modules\n", "Python itself only provides some fundamental functionalities. Others are encapsulated into different modules, either built-in or external. You need to `import` these modules before you can use them. " ] }, { "cell_type": "code", "execution_count": 70, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3.141592653589793\n" ] } ], "source": [ "import math\n", "print(math.pi)" ] }, { "cell_type": "code", "execution_count": 71, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "28.274333882308138\n" ] } ], "source": [ "# Calculate the area of a circle with radius 3\n", "\n", "r = 3.0\n", "a = math.pi * r ** 2\n", "print(a)" ] }, { "cell_type": "code", "execution_count": 73, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on module math:\n", "\n", "NAME\n", " math\n", "\n", "MODULE REFERENCE\n", " https://docs.python.org/3.7/library/math\n", " \n", " The following documentation is automatically generated from the Python\n", " source files. It may be incomplete, incorrect or include features that\n", " are considered implementation detail and may vary between Python\n", " implementations. When in doubt, consult the module reference at the\n", " location listed above.\n", "\n", "DESCRIPTION\n", " This module is always available. It provides access to the\n", " mathematical functions defined by the C standard.\n", "\n", "FUNCTIONS\n", " acos(x, /)\n", " Return the arc cosine (measured in radians) of x.\n", " \n", " acosh(x, /)\n", " Return the inverse hyperbolic cosine of x.\n", " \n", " asin(x, /)\n", " Return the arc sine (measured in radians) of x.\n", " \n", " asinh(x, /)\n", " Return the inverse hyperbolic sine of x.\n", " \n", " atan(x, /)\n", " Return the arc tangent (measured in radians) of x.\n", " \n", " atan2(y, x, /)\n", " Return the arc tangent (measured in radians) of y/x.\n", " \n", " Unlike atan(y/x), the signs of both x and y are considered.\n", " \n", " atanh(x, /)\n", " Return the inverse hyperbolic tangent of x.\n", " \n", " ceil(x, /)\n", " Return the ceiling of x as an Integral.\n", " \n", " This is the smallest integer >= x.\n", " \n", " copysign(x, y, /)\n", " Return a float with the magnitude (absolute value) of x but the sign of y.\n", " \n", " On platforms that support signed zeros, copysign(1.0, -0.0)\n", " returns -1.0.\n", " \n", " cos(x, /)\n", " Return the cosine of x (measured in radians).\n", " \n", " cosh(x, /)\n", " Return the hyperbolic cosine of x.\n", " \n", " degrees(x, /)\n", " Convert angle x from radians to degrees.\n", " \n", " erf(x, /)\n", " Error function at x.\n", " \n", " erfc(x, /)\n", " Complementary error function at x.\n", " \n", " exp(x, /)\n", " Return e raised to the power of x.\n", " \n", " expm1(x, /)\n", " Return exp(x)-1.\n", " \n", " This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.\n", " \n", " fabs(x, /)\n", " Return the absolute value of the float x.\n", " \n", " factorial(x, /)\n", " Find x!.\n", " \n", " Raise a ValueError if x is negative or non-integral.\n", " \n", " floor(x, /)\n", " Return the floor of x as an Integral.\n", " \n", " This is the largest integer <= x.\n", " \n", " fmod(x, y, /)\n", " Return fmod(x, y), according to platform C.\n", " \n", " x % y may differ.\n", " \n", " frexp(x, /)\n", " Return the mantissa and exponent of x, as pair (m, e).\n", " \n", " m is a float and e is an int, such that x = m * 2.**e.\n", " If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0.\n", " \n", " fsum(seq, /)\n", " Return an accurate floating point sum of values in the iterable seq.\n", " \n", " Assumes IEEE-754 floating point arithmetic.\n", " \n", " gamma(x, /)\n", " Gamma function at x.\n", " \n", " gcd(x, y, /)\n", " greatest common divisor of x and y\n", " \n", " hypot(x, y, /)\n", " Return the Euclidean distance, sqrt(x*x + y*y).\n", " \n", " isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0)\n", " Determine whether two floating point numbers are close in value.\n", " \n", " rel_tol\n", " maximum difference for being considered \"close\", relative to the\n", " magnitude of the input values\n", " abs_tol\n", " maximum difference for being considered \"close\", regardless of the\n", " magnitude of the input values\n", " \n", " Return True if a is close in value to b, and False otherwise.\n", " \n", " For the values to be considered close, the difference between them\n", " must be smaller than at least one of the tolerances.\n", " \n", " -inf, inf and NaN behave similarly to the IEEE 754 Standard. That\n", " is, NaN is not close to anything, even itself. inf and -inf are\n", " only close to themselves.\n", " \n", " isfinite(x, /)\n", " Return True if x is neither an infinity nor a NaN, and False otherwise.\n", " \n", " isinf(x, /)\n", " Return True if x is a positive or negative infinity, and False otherwise.\n", " \n", " isnan(x, /)\n", " Return True if x is a NaN (not a number), and False otherwise.\n", " \n", " ldexp(x, i, /)\n", " Return x * (2**i).\n", " \n", " This is essentially the inverse of frexp().\n", " \n", " lgamma(x, /)\n", " Natural logarithm of absolute value of Gamma function at x.\n", " \n", " log(...)\n", " log(x, [base=math.e])\n", " Return the logarithm of x to the given base.\n", " \n", " If the base not specified, returns the natural logarithm (base e) of x.\n", " \n", " log10(x, /)\n", " Return the base 10 logarithm of x.\n", " \n", " log1p(x, /)\n", " Return the natural logarithm of 1+x (base e).\n", " \n", " The result is computed in a way which is accurate for x near zero.\n", " \n", " log2(x, /)\n", " Return the base 2 logarithm of x.\n", " \n", " modf(x, /)\n", " Return the fractional and integer parts of x.\n", " \n", " Both results carry the sign of x and are floats.\n", " \n", " pow(x, y, /)\n", " Return x**y (x to the power of y).\n", " \n", " radians(x, /)\n", " Convert angle x from degrees to radians.\n", " \n", " remainder(x, y, /)\n", " Difference between x and the closest integer multiple of y.\n", " \n", " Return x - n*y where n*y is the closest integer multiple of y.\n", " In the case where x is exactly halfway between two multiples of\n", " y, the nearest even value of n is used. The result is always exact.\n", " \n", " sin(x, /)\n", " Return the sine of x (measured in radians).\n", " \n", " sinh(x, /)\n", " Return the hyperbolic sine of x.\n", " \n", " sqrt(x, /)\n", " Return the square root of x.\n", " \n", " tan(x, /)\n", " Return the tangent of x (measured in radians).\n", " \n", " tanh(x, /)\n", " Return the hyperbolic tangent of x.\n", " \n", " trunc(x, /)\n", " Truncates the Real x to the nearest Integral toward 0.\n", " \n", " Uses the __trunc__ magic method.\n", "\n", "DATA\n", " e = 2.718281828459045\n", " inf = inf\n", " nan = nan\n", " pi = 3.141592653589793\n", " tau = 6.283185307179586\n", "\n", "FILE\n", " /Users/wenchang/miniconda3/envs/junior/lib/python3.7/lib-dynload/math.cpython-37m-darwin.so\n", "\n", "\n" ] } ], "source": [ "help(math)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Reference\n", "\n", "* https://docs.python.org/3/tutorial/index.html\n", "* http://pycourse.princeton.edu" ] } ], "metadata": { "colab": { "collapsed_sections": [], "name": "python101.ipynb", "provenance": [], "toc_visible": true }, "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.3" } }, "nbformat": 4, "nbformat_minor": 1 }