Lecture C: Getting Started with Writing in Jupyter

Introduction


The humane markup language called Markdown is the primary way of writing text in Jupyter notebooks. The purpose of this section is to get the user familiar with the basics of markdown. There are numerous tutorials on the web. What is presented below is the bare minimum needed to develop a notebook that can communicate the users' methodology to an unfamiliar reader. Additional sources of information:

What is Markdown?


A markup language uses a command syntax inline with the content of a document. You are probably most familiar with HTML, but there are others.

These languages can be challenging to use if you are starting out or if you are not used to programming. HTML, in partcular, looks more like computer code then what you (ultimately) want to see on a webpage. This is off-putting for content developers.

Attitudes now favor writing the content of documents so that they are human readable, and then permitting software (that other people write) to transform your document into something that looks different (usually nicer or more professional) or displays the content in a different type of software where the software controls the formatting. LaTeX is a very mature example of a markup language that scientists and engineers use to prepare formal reports and journal articles. For the most part, a LaTeX document can easily be read by a non-LaTeX programmer.

Recently the idea of more humane markup languages has emerged. These languages can easily be read in raw form but they can also be translated by other computer programs into other types of documents.

If you've ever sent a text message and used quotes: " ", asterisks: , or underlines: around a word, then you've already written in a type of "markdown". Software intended for the web generally will have some form of markdown available.

We feel that focusing on human readable content is an appropriate activity for faculty. Sticking to markdown syntax makes it possible for other software packages to interpret your content and create interactive notebooks, slides, homework assignments, course notes, etc.

Paragraphs


Type text to make a paragraph. For example:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum interdum eu arcu a porttitor. Aliquam a mauris urna. Nulla id dignissim arcu. Nunc at venenatis ligula. Etiam massa dui, pellentesque ornare sollicitudin et, pulvinar eget massa. Vestibulum at commodo nulla. Vivamus suscipit eget magna ut luctus. Nunc ut iaculis dui. Pellentesque molestie pharetra metus, in ullamcorper urna dignissim quis. Phasellus ac tempus sem.

renders as:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum interdum eu arcu a porttitor. Aliquam a mauris urna. Nulla id dignissim arcu. Nunc at venenatis ligula. Etiam massa dui, pellentesque ornare sollicitudin et, pulvinar eget massa. Vestibulum at commodo nulla. Vivamus suscipit eget magna ut luctus. Nunc ut iaculis dui. Pellentesque molestie pharetra metus, in ullamcorper urna dignissim quis. Phasellus ac tempus sem.

A blank line between will start a new paragraph.

Headings


Hash symbols and the number of them decide the heading level. See other cells in this notebook for additional examples.

### Headings

Line Breaks


Sometimes you will want to break the line manually. Type two spaces at the end of a line to break the line:

(With two spaces at the end of every line)
The quick brown fox
jumps over the lazy dog

(Without two spaces at the end of every line) The quick brown fox jumps over the lazy dog

Emphasis


For example:

**Hello World!**

_Hello World!_

produces:

Hello World!

Hello World!

Lists


* Item 1
* Item 2
* Item 3

  • Item 1
  • Item 2
  • Item 3

Equations


LaTeX is used to typeset equations. For example:

$$ \frac{\partial c}{\partial t} = D \frac{\partial^2 c}{\partial x^2} $$

renders as:

$$ \frac{\partial c}{\partial t} = D \frac{\partial^2 c}{\partial x^2} $$

Single $ puts equations inline. Double $$ centers the equations in the cell. Some other helpful examples:

  • Superscript, x^2 = $x^2$
  • Subscript, x_0 = $x_0$
  • Grouping, x^{-2} = $x^{-2}$ (use curly braces)
  • Fractions, \frac{3}{4} = $\frac{3}{4}$ (also good for derivative symbols)
  • Partial derivatives, \frac{\partial c}{\partial t} = $\frac{\partial c}{\partial t}$
  • Scientific notation, 1 \times 10^{-5} = $1 \times 10^{-5}$
  • Functions, \sin{3x} = $\sin{3x}$, also $\cos{5x}$, $\tan{7x}$, $\sqrt{56}$

The cheat sheet has a lot more options, but not all symbols are implemented.

Images


Markdown syntax provides for including images.

![Alt Text](./images/3dglasses.gif "Pointer Hover Title")

Tables


|Header|Header|Header|Header| |------|------|------|------| |Cell |Cell |Cell | Cell | |Cell |Cell |Cell | Cell | |Cell |Cell |Cell | Cell | |Cell |Cell |Cell | Cell |

Header Header Header Header
Cell Cell Cell Cell
Cell Cell Cell Cell
Cell Cell Cell Cell
Cell Cell Cell Cell

Python Code


Enter your code, then type <SHIFT>+<ENTER> to execute.


In [1]:
2+2


Out[1]:
4

Homework


Write a 250-500 word essay on representation of numbers by computers. Include topics such as machine accuracy, bit length, types (e.g. int, float, long) and exact representations. Use diagrams and figures where appropriate.


In [ ]: