diff --git a/01_jupyter_howto.ipynb b/01_jupyter_howto.ipynb index 71689cb..e2523fd 100644 --- a/01_jupyter_howto.ipynb +++ b/01_jupyter_howto.ipynb @@ -15,7 +15,7 @@ "\n", "What is an interactive Python notebook? It is a notebook that mixes documentation (like this!) with Python code (like below), with the output of that code.\n", "\n", - "For example, below is the Python code to print \"Hello World\". Click on the below code and then press \"SHIFT+Return\". You should see that the code is run, and below \"Hello World\" will be printed." + "For example, the cell below contains the Python code to print \"Hello World\". Click on the below code and then press \"CTRL+Return\". You should see that the code is run, and below \"Hello World\" will be printed." ] }, { @@ -31,9 +31,28 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The above code is interactive because it runs when you pressed \"SHIFT+Return\". It is also interactive because you can change it. For example, click again on the code and change \"Hello World\" to \"Hello Jupyter\". Press \"SHIFT+Return\" again and you should see \"Hello Jupyter\" printed.\n", + "The above code is interactive because it runs when you pressed \"CTRL+Return\". It is also interactive because you can change it. For example, click again on the code and change \"Hello World\" to \"Hello Jupyter\". Press \"CTRL+Return\" again and you should see \"Hello Jupyter\" printed.\n", "\n", - "A code cell can have as much or little Python in it as you want. The below cell defines a function and then runs it in a loop. What do you think will be printed out when you select it and press \"SHIFT+Return\"? Have a go. Are you right?" + "Pressing \"CTRL+Return\" repeatedly allows you to re-run the contents of a cell many times. Try repeatedly running the cell below." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from random import randint\n", + "print(randint(0, 10))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A code cell can have as much or little Python in it as you want. The below cell defines a function and then runs it in a loop. What do you think will be printed out when you select it and press \"CTRL+Return\"? Have a go. Are you right?\n", + "\n", + "Try pressing \"SHIFT+Return\". This time, as well as the cell being executed, the focus moved to the cell below. By continually pressing \"SHIFT+Return\" you can navigate through a notebook cell-by-cell." ] }, { @@ -280,13 +299,6 @@ "Have a play. Explore the buttons and menu items. Take a look at the \"Help\" in the menu. Remember that, if everything goes wrong, you can always click \"Stop\" or select \"Kernel | Restart & Clear Output\" from the menu." ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, { "cell_type": "markdown", "metadata": {}, @@ -368,13 +380,6 @@ "Alternatively, you can save a copy of this notebook under a different name by clicking \"File | Make a Copy...\" in the menu. You can then copy this file or send it to someone else. As a notebook contains the code, data, outputs and analysis, sharing notebooks is the closest thing we have to interactive papers. This is a really powerful concept and, I believe, will fundementally change how we report and share the results of computational and data analysis in science." ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, { "cell_type": "markdown", "metadata": {}, @@ -437,13 +442,6 @@ "\n", "Thanks to the [Microsoft Azure Kubernetes Service](https://docs.microsoft.com/en-us/azure/aks/) on which this Jupyter image is running." ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { @@ -462,7 +460,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.2" + "version": "3.5.4" } }, "nbformat": 4, diff --git a/answers/01_jupyter_howto.ipynb b/answers/01_jupyter_howto.ipynb index e32c51f..c1d353b 100644 --- a/answers/01_jupyter_howto.ipynb +++ b/answers/01_jupyter_howto.ipynb @@ -15,7 +15,7 @@ "\n", "What is an interactive Python notebook? It is a notebook that mixes documentation (like this!) with Python code (like below), with the output of that code.\n", "\n", - "For example, below is the Python code to print \"Hello World\". Click on the below code and then press \"SHIFT+Return\". You should see that the code is run, and below \"Hello World\" will be printed." + "For example, the cell below contains the Python code to print \"Hello World\". Click on the below code and then press \"CTRL+Return\". You should see that the code is run, and below \"Hello World\" will be printed." ] }, { @@ -39,15 +39,42 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The above code is interactive because it runs when you pressed \"SHIFT+Return\". It is also interactive because you can change it. For example, click again on the code and change \"Hello World\" to \"Hello Jupyter\". Press \"SHIFT+Return\" again and you should see \"Hello Jupyter\" printed.\n", + "The above code is interactive because it runs when you pressed \"CTRL+Return\". It is also interactive because you can change it. For example, click again on the code and change \"Hello World\" to \"Hello Jupyter\". Press \"CTRL+Return\" again and you should see \"Hello Jupyter\" printed.\n", "\n", - "A code cell can have as much or little Python in it as you want. The below cell defines a function and then runs it in a loop. What do you think will be printed out when you select it and press \"SHIFT+Return\"? Have a go. Are you right?" + "Pressing \"CTRL+Return\" repeatedly allows you to re-run the contents of a cell many times. Try repeatedly running the cell below." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "5\n" + ] + } + ], + "source": [ + "from random import randint\n", + "print(randint(0, 10))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A code cell can have as much or little Python in it as you want. The below cell defines a function and then runs it in a loop. What do you think will be printed out when you select it and press \"CTRL+Return\"? Have a go. Are you right?\n", + "\n", + "Try pressing \"SHIFT+Return\". This time, as well as the cell being executed, the focus moved to the cell below. By continually pressing \"SHIFT+Return\" you can navigate through a notebook cell-by-cell." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -85,38 +112,22 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ - "x = 21" + "x = 5" ] }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "21...\n", - "20...\n", - "19...\n", - "18...\n", - "17...\n", - "16...\n", - "15...\n", - "14...\n", - "13...\n", - "12...\n", - "11...\n", - "10...\n", - "9...\n", - "8...\n", - "7...\n", - "6...\n", "5...\n", "4...\n", "3...\n", @@ -162,7 +173,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -176,7 +187,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "7fe11cc237114eadb39b84e672bddf3d", + "model_id": "904bdd0e82f340cf91e31996864cae0a", "version_major": 2, "version_minor": 0 }, @@ -205,7 +216,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "de114cb2c0664de99016dfb85a2f452c", + "model_id": "58130e6132cb464c86c722052ed163e0", "version_major": 2, "version_minor": 0 }, @@ -225,7 +236,7 @@ "
\n" ], "text/plain": [ - "Tab(children=(Box(children=(Box(children=(Box(children=(Label(value='step'), IntSlider(value=1, min=-100)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='delay'), IntSlider(value=100, max=1000, min=10)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='background'), ColorPicker(value='white')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='camera'), Dropdown(options=('perspective', 'orthographic'), value='perspective')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value=''), HBox(children=(ToggleButton(value=False, description='Smoothing', tooltip='smoothing trajectory'), Button(description=' Center', icon='bullseye', style=ButtonStyle()), Button(description=' Screenshot', icon='camera', style=ButtonStyle()), Button(description='qtconsole', style=ButtonStyle(), tooltip='pop up qtconsole')), layout=Layout(flex='1 1 auto', width='auto'))), layout=Layout(display='flex', flex_flow='row', justify_content='space-between'))), layout=Layout(align_items='stretch', display='flex', flex_flow='column', width='100%')),)), Box(), Box(), Box(), Box(), Box()), layout=Layout(align_items='stretch', align_self='center'), _titles={'4': 'Extra', '2': 'Preference', '3': 'Theme', '1': 'Representation', '0': 'General', '5': 'Help'})" + "Tab(children=(Box(children=(Box(children=(Box(children=(Label(value='step'), IntSlider(value=1, min=-100)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='delay'), IntSlider(value=100, max=1000, min=10)), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='background'), ColorPicker(value='white')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value='camera'), Dropdown(options=('perspective', 'orthographic'), value='perspective')), layout=Layout(display='flex', flex_flow='row', justify_content='space-between')), Box(children=(Label(value=''), HBox(children=(ToggleButton(value=False, description='Smoothing', tooltip='smoothing trajectory'), Button(description=' Center', icon='bullseye', style=ButtonStyle()), Button(description=' Screenshot', icon='camera', style=ButtonStyle()), Button(description='qtconsole', style=ButtonStyle(), tooltip='pop up qtconsole')), layout=Layout(flex='1 1 auto', width='auto'))), layout=Layout(display='flex', flex_flow='row', justify_content='space-between'))), layout=Layout(align_items='stretch', display='flex', flex_flow='column', width='100%')),)), Box(), Box(), Box(), Box(), Box()), layout=Layout(align_items='stretch', align_self='center'), _titles={'5': 'Help', '3': 'Theme', '0': 'General', '1': 'Representation', '4': 'Extra', '2': 'Preference'})" ] }, "metadata": {}, @@ -243,23 +254,23 @@ "source": [ "You can rotate and interact with molecules once they have loaded (the \"[*]\" next to a cell indicates that it is processing. It will turn into a number once processing is complete)\n", "\n", - "You can change molecular representations and interact with the 3D molecule view. Later on we will go through some examples showing what you can do and how you can select parts of the molecule.\n", + "You can change molecular representations and interact with the 3D molecule view. [Later on](16_viewing_molecules.ipynb) we will go through some examples showing what you can do and how you can select parts of the molecule (or [click here](16_viewing_molecules.ipynb) if you want to jump ahead and learn now).\n", "\n", "In addition to viewing molecules, you can also draw graphs. This is achieved using a combination of the [matplotlib](https://matplotlib.org), [numpy](http://www.numpy.org) and [pandas](https://pandas.pydata.org) modules. For example, the below code draws a sine and cosine curve." ] }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "