Skip to content

Commit

Permalink
updates before class
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale committed Jan 26, 2025
1 parent 79d822c commit c0a21c7
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 17 deletions.
6 changes: 3 additions & 3 deletions content/01-python/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Some resources for practicing on your own:

## Online books:

* [Think python](http://www.greenteapress.com/thinkpython/)
* [Think python](https://greenteapress.com/wp/think-python-3rd-edition/)

* [Dive into Python](http://www.diveintopython.net/)
* [Dive into Python](https://diveintopython3.net/)

* [SciPy Lecture Notes](http://scipy-lectures.github.io/)

Expand All @@ -36,7 +36,7 @@ Some resources for practicing on your own:

* Astronomy: [AstroPy](http://astropy.org)

* Atmospheric sciences: [PyAOS](http://pyaos.johnny-lin.com/)
* Atmospheric sciences: [PyAOS](https://pyaos.github.io/)

* Biology: [Biopython](http://biopython.org/)

Expand Down
2 changes: 2 additions & 0 deletions content/01-python/installing.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ https://www.anaconda.com/products/individual

This will install everything that you need.

```{tip}
If you have trouble getting a local install working, most of the class
material will work automatically in the cloud, either on
[binder](https://mybinder.org/) or [google
colab](https://research.google.com/colaboratory/).
```

If you have python successfully installed, you should be able to start
the python interpreter at the command line as: `python`. A shell will
Expand Down
48 changes: 38 additions & 10 deletions content/01-python/w1-jupyter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,30 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We interact with python by typing into _cells_ in the notebook. By default, a cell is a _code_ cell, which means that you can enter any valid python code into it and run it. Another important type of cell is a _markdown_ cell. This lets you put text, with different formatting (italics, bold, etc) that describes what the notebook is doing.\n",
"````{note}\n",
"There are several interfaces to [Jupyter](https://jupyter.org/).\n",
"\n",
"You can change the cell type via the menu at the top, or using the shortcuts:\n",
"We will use *JupyterLab*, which is traditionally started at the command line via:\n",
"```\n",
"jupyter lab\n",
"```\n",
"\n",
" * ctrl-m m : mark down cell\n",
" * ctrl-m y : code cell"
"The older (classic) interface is *Jupyter Notebook*, which can be started via:\n",
"```\n",
"jupyter notebook\n",
"```\n",
"````"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Some useful short-cuts:\n",
"We interact with python by typing into _cells_ in the notebook. \n",
"\n",
" * shift+enter = run cell and jump to the next (creating a new cell if there is no other new one)\n",
" * ctrl+enter = run cell-in place\n",
" * alt+enter = run cell and insert a new one below\n",
"By default, a cell is a _code_ cell, which means that you can enter any valid python code into it and run it. \n",
"\n",
"ctrl+m h lists other commands"
"Another important type of cell is a _markdown_ cell. This lets you put text, with different formatting (italics, bold, etc) that describes what the notebook is doing."
]
},
{
Expand All @@ -51,6 +56,29 @@
"$$\\frac{\\partial \\rho}{\\partial t} + \\nabla \\cdot (\\rho U) = 0$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{tip}\n",
"You can change the cell type via the menu at the top, or using the shortcuts:\n",
"\n",
" * ctrl-m m : mark down cell\n",
" * ctrl-m y : code cell\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Some useful short-cuts:\n",
"\n",
" * shift+enter = run cell and jump to the next (creating a new cell if there is no other new one)\n",
" * ctrl+enter = run cell-in place\n",
" * alt+enter = run cell and insert a new one below"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -148,7 +176,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.13.1"
}
},
"nbformat": 4,
Expand Down
15 changes: 11 additions & 4 deletions content/01-python/w1-python-datatypes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"source": [
"```{note}\n",
"Integer division is one place where python and other programming languages differ.\n",
"In python, dividing 2 integers results in a float. In C/C++/Fortran, dividing 2 integers results in an integer, so `1/2 = 0`.\n",
"In python, dividing two integers results in a float. In C/C++/Fortran, dividing two integers results in an integer, so `1/2 = 0`.\n",
"```"
]
},
Expand Down Expand Up @@ -501,13 +501,20 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"It is important to understand that since there are infinitely many real numbers between any two bounds, on a computer we have to approximate this by a finite number. There is an IEEE standard for floating point that pretty much all languages and processors follow. \n",
"```{important}\n",
"Not every number can be represented in floating point. Since there are infinitely many real numbers between any two bounds but we are using a finite amount of memory, on a computer we have to approximate numbers. There is an IEEE standard for floating point that pretty much all languages and processors follow. \n",
"\n",
"The means two things\n",
"\n",
"* not every real number will have an exact representation in floating point\n",
"* there is a finite precision to numbers -- below this we lose track of differences (this is usually called *roundoff* error)\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Consider the following expression, for example:"
]
},
Expand Down Expand Up @@ -537,7 +544,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Here's another example: The number 0.1 cannot be exactly represented on a computer. In our print, we use a format specifier (the stuff inside of the {}) to ask for more precision to be shown:"
"Here's another example: The number 0.1 cannot be exactly represented on a computer. In our print, we use a format specifier (the stuff inside of the `{}`) to ask for more precision to be shown:"
]
},
{
Expand Down

0 comments on commit c0a21c7

Please sign in to comment.