{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# [MCB 32L]: Introduction to Python\n",
"---\n",
"\n",
"### Professor Robin Ball\n",
"\n",
"We will introduce you to data analysis using Python and Jupyter notebooks, which you will use in other labs this semester.\n",
"\n",
"*Estimated Time: ~1 Hour*\n",
"\n",
"---\n",
"\n",
"### Table of Contents\n",
"\n",
"Intro to Jupyter notebooks
\n",
"\n",
"1. Introduction to Python
\n",
"\n",
" a Entering and Naming your data
\n",
"\n",
" b Basic calculations
\n",
" \n",
"2. Graphing with `matplotlib`
\n",
"\n",
"3. Graphing reaction time data
\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Welcome to Jupyter \n",
"\n",
"Welcome to the Jupyter Notebook! **Notebooks** are documents that can contain text, code, visualizations, and more. We'll be using them in this lab to manipulate and visualize our data.\n",
"\n",
"A notebook is composed of rectangular sections called **cells**. There are two kinds of cells: markdown and code. A **markdown cell**, such as this one, contains text. A **code cell** contains code in Python, a programming language that we will be using for the remainder of this module. You can select any cell by clicking it once. After a cell is selected, you can navigate the notebook using the up and down arrow keys.\n",
"\n",
"To run a code cell once it's been selected, \n",
"- press Shift-Enter, or\n",
"- click the Run button in the toolbar at the top of the screen. \n",
"\n",
"If a code cell is running, you will see an asterisk (\\*) appear in the square brackets to the left of the cell. Once the cell has finished running, a number will replace the asterisk and any output from the code will appear under the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# run this cell\n",
"print(\"Hello World!\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You'll notice that many code cells contain lines of blue text that start with a `#`. These are *comments*. Comments often contain helpful information about what the code does or what you are supposed to do in the cell. The leading `#` tells the computer to ignore them."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# this is a comment- running the cell will do nothing!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Code cells can be edited any time after they are highlighted. Try editing the next code cell to print your name."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# edit the code to print your name\n",
"print(\"Hello: my name is (name)\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Saving and Loading\n",
"\n",
"Your notebook can record all of your text and code edits, as well as any graphs you generate or calculations you make. You can save the notebook in its current state by clicking Control-S, clicking the floppy disc icon in the toolbar at the top of the page, or by going to the File menu and selecting \"Save and Checkpoint\".\n",
"\n",
"The next time you open the notebook, it will look the same as when you last saved it.\n",
"\n",
"**Note:** after loading a notebook you will see all the outputs (graphs, computations, etc) from your last session, but you won't be able to use any variables you assigned or functions you defined. You can get the functions and variables back by re-running the cells where they were defined- the easiest way is to highlight the cell where you left off work, then go to the Cell menu at the top of the screen and click \"Run all above\". You can also use this menu to run all cells in the notebook by clicking \"Run all\"."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Completing the Notebooks\n",
"\n",
"\n",
"