We will be using jupyter notebooks exclusively in this class, so it will be worthwhile to get to know some shortcuts & overall functionality.
Each little block of text or code is called a "cell." There are two types: either code, or text. If you are writing text, it is being processed by default as markdown. Markdown is a simple & common markup language. If you have tried to write your own webpage or used Github, you've probably used Markdown.
For the purposes of this class, writing "markdown" will basically just involve writing simple text. However, here are a few useful text styles:
Italics: wrap the text to italicize with asterisks, like *this* (this)
Bold: wrap the text to bold with double asterisks, like **this** (this)
Hyperlinks: [text to display](https://mywebsitehere.com)
Headings: place hashtags in front of text. The fewer the number of hashtags, the larger the font. E.g.,
# Big title
## subtitle
### sub-subtitle
Bullet lists: place single asterisk before each item:
* item1
* item2
* item3
Math in markdown looks similar to math in LaTeX. Dollar signs around math code will display math:
$$ \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15} $$
Here is a handy "cheat sheet" for how to write math in a Jupyter notebook.
Pressing esc will switch into "command mode." From here, you can skip the mouse and use simple keyboard shortcuts to do everything. For example:
Ctrl + Shift + - will split the current cell into two from where your cursor is.D + D (press the key twice) to delete the current cell.Shift + j or Shift + Down or Shift + k or Shift + upShift + mFor more tips and tricks, you can bookmark this page
To run your code, hit Shift + enter.
by prepending a library, method or variable with ?, you can access the Docstring for quick reference.
Avoid long strings of commented text inside a code cell. If you find yourself doing this a lot, break the cell and write in markdown.
We will be relying primarily on a handful of python libraries for this class. I encourage you to look up the documentation for each of them and see what they are for and what their strengths are.
If you are relatively new to coding, you will need to familiarize yourself with a few basics, as this is not an intro to python class. However, it is a learning objective for this class that you gain familiarity with coding in python.
You are not expected to know anything "off the bat," however, it will be your responsibility to fill in any gaps of knowledge so that we can move forward at an appropropriate pace. Quiz material will occasionally have coding questions typically about some kind of function or operation emphasized in the week's lectures.
Here are a few handy tricks and tips for working at the command line if this is new to you. My goal is to convert at least one student to working at the command line!
The syntax for command line commands is: $ command -options input. Many commands (like functions you will build yourselves) have default *arguments* meaning that you don't have to specify any options or any input for the command to do something.
For instance,
$ ls is short for the word "list" and is a command that will print out all non-hidden files in the current directory. So the default option is "none" and the default input is the current directory. If you type at the command line:
$ ls -a adds the "all" option which will show all files including hidden ones (which will start with a ".")
Here are some of the most useful commands you may want to know about files, paths, and directory manipulations:
ls lists all files cd stands for "change directory" you can follow this with an absolute path (e.g., /Users/carthur/Documents/MyStuff) or a path relative to the one you are in...
cd .. goes backwards to the parent directorycd ./SomeOtherFolder goes from your current location (".") to a sub-folder called "SomeOtherFolder"cd /Users/carthur/Documents/MyStuff will take me to that specific folder no matter my current location~ ("tilda") is a shortcut referencing your home directory. You can change this at any time to be whatever you want, but usually by default is your /Users/computerName on a Mac or your main documents or desktop folder on Windows. So cd ~ takes me to $/Users/carthur no matter where I am currently.mkdir NameOfDirectory will create a new directory (under your current directory)tab. If the system knows about it, it will finish it for you. If there are multiple items that start the same but end differently, it will complete up to the point of differentiation. E.g., if I start typing "syllabus" in my directory but I have two syllabi called syllabus2019 and syllabus2020, it will only complete through the end of the word "syllabus" and wait for you to differentiate which one you want. If you then hit tab again, it will show you all files beginning with "syllabus".more NameOfFilethis will print out--in groups of lines at a time--the contents of the file you pass as inputCtrl-cwill force exit a process, file, or application. For example, if you use the more command on an unfortunately large file and don't want to scroll all the way through, you can type Ctrl-c.