{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Intro to coding with a Jupyter notebook\n", "This is a Jupyter notebook. It allows you to type text, format it with headings and links, insert images, and have separate cells for code. You can click the \"play\" icon above (or shift+ENTER) to execute a cell and go on to the next one. You can also edit the code and run it again to see how the output changes.\n", "\n", "Click on this cell, then press shift+ENTER." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, try executing the following cells." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# This is how to add.\n", "2+2" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# This is a \"comment\"\n", "# Starting with # tells the program not to read this line\n", "5-4" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# the following lines \"define variables\"\n", "a = 4\n", "b = 3\n", "\n", "# If you're used to other languages, Python doesn't need the \"print\" command\n", "# the next line displays the result\n", "a+b" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "c = a*a\n", "c" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Can you figure out what this operation is?\n", "d = b**a\n", "d" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "You can re-execute a cell by pressing shift+ENTER. Try editing some of the code above.\n", "- Edit some code to do a different calculation\n", "- Add a comment in a code cell to explain what the code does\n", "- Figure out what that last calculation does\n", "\n", "You can **save** by clicking on the disk icon in the top toolbar. \n", "To **download a static pdf** version (for printing or to show someone without Jupyter installed), go to File > Download as > PDF via LaTex. \n", "To **start over** from scratch: on the toolbar above click Kernel > Restart and Clear Output." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Markdown\n", "This is a *markdown cell* which contains markdown text. That's text that isn't read as Python code. Instead, you can format markdown text to look nice. If you double-click on a markdown cell (like this one) you can see the code that formats this text. It's pretty simple. \n", "- here's a bullet point\n", "- and another list item\n", "- this one has a hyperlink to this [treasure of the internet](https://www.youtube.com/watch?v=dQw4w9WgXcQ)\n", "- You can even embed images \n", "![title](https://imgs.xkcd.com/comics/mu.png)\n", "\n", "Read about [formatting the markdown text](https://help.github.com/articles/basic-writing-and-formatting-syntax/) in a cell, like this one, or go to Help > Markdown > Basic Writing and Formatting Text." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "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.5.2" } }, "nbformat": 4, "nbformat_minor": 0 }