{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Using these notebooks" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This workbench is created using Jupyter notebooks. Jupyter lets you combine text, images, and live code within a single web page. So not only can you read about collections data, you can download it, analyse it, and visualise it – all within your browser!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Running code cells" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Most of the notebooks here include snippets of real code contained within cells. To run these snippets, just click on the cell and hit **Shift+Enter**. Try it with the cell below!" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# CLICK ON ME AND THEN HIT SHIFT+ENTER!\n", "\n", "# This makes the datetime module available to use\n", "import datetime\n", "\n", "# This creates a variable called 'date_now' and uses the datetime.date.today() function to set it to today's date.\n", "date_now = datetime.date.today()\n", "\n", "# This displays a nicely-formatted string containing the date\n", "print(\"Congratulations! On {} you ran the code in this cell.\".format(date_now))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "

**Help! Nothing happens when I click!**

\n", "\n", "\n", "If nothing happens when you click on a cell or hit **Shift+Enter** it's probably because you're viewing a static version of the notebook. See Introduction for setting up a live version.\n", "\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can also run the code in a cell by clicking on the 'Run' icon in the toolbar, or by hitting **Control+Enter**. You'll notice that **Shift+Enter** runs the code and moves you on to the next cell, while **Control+Enter** leaves you where you are." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Any variables or functions defined within a cell are made available to the rest of the notebook when you run it. So we can use the `date_now` variable defined above in any cell." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Run me to see how we can access the 'date_now' variable\n", "\n", "# This gets the year from the date stored in the date_now variable.\n", "date_now.year" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "

**Help! I get a weird 'Name Error' saying that 'date_now' is not defined.**

\n", "If you get a message about a NameError, make sure that you've run the first code cell (where we create the 'date_now' variable, before this one.\n", "\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You might have noticed that after a cell has been run a number appears in the square brackets – `In [ ]:`. This helps you keep track of which cells have been executed. While the code in a cell is running you'll see an asterix – `In [*]:`. This changes to a number once the code has completed.\n", "\n", "Some of the notebooks in this workbench include many code cells defining functions and setting up variables for later use. Just run the cells in the order they appear to make sure that everything works as expected. If you get an error, check back to make sure all the relevant cells have been executed.\n", "\n", "In some cases, cells will start processes that take a bit of time to complete. For example, harvesting series data from RecordSearch can take lots of time depending on how big the series is. You won't be able to run any more cells until the current one has finished. Just wait for the asterix to turn into a number and you'll be right to move on." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Adding and editing cells" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In many places throughout this workbench, you'll be asked to edit or add to the code. That's how you learn! Just click on any code cell to start editing (double click on a Markdown cell). Try this!" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Edit this cell to add your name between the quotes, and then run it\n", "your_name = 'Tim'\n", "print('Hi {}! Welcome to the OzGLAM workbench. 👋'.format(your_name))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To add a new cell, you just click the **+** icon in the toolbar at the top of the page. By default, the new cell will be expecting code, but you can change this by selecting 'Markdown' in the dropdown list of types in the toolbar." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "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.6.5" } }, "nbformat": 4, "nbformat_minor": 2 }