{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Learning Resources"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Learning by doing!**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Online\n",
"\n",
"* The Hitchhiker’s Guide to Python\n",
"http://docs.python-guide.org/en/latest/\n",
"\n",
"* Hard way is easier http://learnpythonthehardway.org\n",
"\n",
"* Google python class\n",
"https://developers.google.com/edu/python/\n",
"\n",
"* Python tutorial\n",
"https://docs.python.org/2/tutorial/\n",
"\n",
"* Python Tutor - code visualizing (developed by MIT)\n",
"http://pythontutor.com/\n",
"\n",
"* If you feel lost: CodeAcademy https://www.codecademy.com/en/tracks/python"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Reading (in the future)\n",
"\n",
"* Al Sweigart, \"Automate the Boring Stuff with Python\", https://automatetheboringstuff.com\n",
"* Mark Lutz, \"Python Pocket Reference\" (250 pages)\n",
"* Mark Lutz, \"Learning Python\" (1600 pages!)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"#Ecosystem"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Nbviewer\n",
"\n",
"* can render any ipython/jupyter notebook from public github repository\n",
"\n",
"Course assignments will be distributed through:\n",
"http://nbviewer.ipython.org/github/oseledets/nla2015/blob/master/table_of_contents.ipynb"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Github\n",
"\n",
"Our course repository - **NLA 2015**:\n",
"https://github.com/oseledets/nla2015\n",
"(clone it to stay updated on new materials)\n",
"\n",
"* github for desktop (very simple in use, somewhat limited in functionality)\n",
"https://desktop.github.com/\n",
"\n",
"* sourcetree (stable, well-designed, feature-rich)\n",
"https://www.sourcetreeapp.com/\n",
"\n",
"* you can also simply use terminal as per docs (https://git-scm.com/documentation)\n",
"* General flow while working on any project (not obligatory though)\n",
"https://guides.github.com/introduction/flow/"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## IDE\n",
"* **notebook (REPL)**\n",
"* IDLE (terminal, shipped with python distribution)\n",
"* qtconsole (terminal, shipped with anaconda)\n",
"* Spyder (IDE, shipped with anaconda)\n",
"* Python Tools for Visual Studio\n",
"* PyCharm\n",
"* Atom, Sublime Text, Vim, Notepad++, etc."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Jupyter Ascending\n",
"http://blog.jupyter.org/2015/08/12/first-release-of-jupyter/\n",
"\n",
"\n",
"\n",
"\n",
"**Ju**lia - **Py**thon - **R**"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## IPython vs Jupyter\n",
"*\"IPython 3 was the last major monolithic release of IPython\"*\n",
"\n",
"\n",
"* **Idea**: separate language-agnostic components, independent lifecycles\n",
"* IPython.kernel ⇒ jupyter_client, ipykernel\n",
"* Code is basically the same\n",
"\n",
"\n",
"More details at:\n",
"* Big Split\n",
"http://blog.jupyter.org/2015/04/15/the-big-split/"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Jupyter / IPython\n",
"\n",
"Key components:\n",
"* kernels (ipython is default)\n",
"* notebook\n",
"* console, qtconsole\n",
"\n",
"*\"IPython is the reference Jupyter kernel, providing a powerful environment for interactive computing in Python\"*"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* installing python, ipython\n",
"https://store.continuum.io/cshop/anaconda/\n",
"\n",
"* updating to jupyter\n",
"```\n",
"conda update ipython\n",
"conda update ipython-notebook\n",
"conda update ipython-qtconsole\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Using ipython/jupyter"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* notebook runs on top of ipython kernel\n",
"* notebook is divided into code cells\n",
"* cell can be of different type (code cell, markdown cell, etc.)\n",
"* edit mode (inside cell) / command mode (outside cell)\n",
"* for quick navigation and hotkeys see *Help - Keyboard Shortcuts*\n",
" * you might want to remember at least these: a, b, c, x, y, z, v, m, l\n",
" * `CTRL+/` or `Command+/` for commenting\n",
" * `CTRL+[]` or `Command+[]` for indentation\n",
" * `CTRL+SHIFT+\"-\"` for splitting, `SHIFT+M` for merging cells\n",
"* examples of markdown and tex can be found in any lecture notebook (just double-click any cell)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Markdown text with formulas inline : $a_{ij} = g_{i+j}$\n",
"\n",
"Centered formula:\n",
"$$ a_{ij} = \\frac{g_{i+j}}{L^2} $$"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"# How to work with home assignments\n",
"\n",
"* divide into blocks\n",
"* each block - separate task\n",
"* use sub-heading and markdown to explain things\n",
"\n",
"Assignments must be submitted to **Stellar** http://stellar.mit.edu/.\n",
"\n",
"Our course page:\n",
"https://stellar.mit.edu/S/project/numericallinalg/\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Programming in python"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## writing code\n",
"* code should be readable first!\n",
"\n",
"* style guides\n",
" * PEP8 (PEP = Python Enhancement Proposal) http://legacy.python.org/dev/peps/pep-0008/\n",
" * writing idiomatic code http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"source": [
"## Understanding the code\n",
"\n",
"Usually code in python is slef-explanatory. However, if you don't understand something it might be helpful to vizualize it with Python Tutor:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from IPython.display import HTML\n",
"HTML(\"\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Some anti-patterns\n",
"*how not to code*\n",
"\n",
"looping through dictionaries\n",
"http://docs.quantifiedcode.com/python-anti-patterns/performance/index.html\n",
"\n",
"using wildcard imports (from ... import *)\n",
"http://docs.quantifiedcode.com/python-anti-patterns/maintainability/from_module_import_all_used.html\n",
"\n",
"\n",
"Using single letter to name your variables\n",
"http://docs.quantifiedcode.com/python-anti-patterns/maintainability/using_single_letter_as_variable_name.html\n",
"\n",
"\n",
"Comparing things to None the wrong way\n",
"http://docs.quantifiedcode.com/python-anti-patterns/readability/comparison_to_none.html\n",
"\n",
"\n",
"Comparing things to True the wrong way\n",
"http://docs.quantifiedcode.com/python-anti-patterns/readability/comparison_to_true.html\n",
"\n",
"\n",
"Using type() to compare types\n",
"http://docs.quantifiedcode.com/python-anti-patterns/readability/do_not_compare_types_use_isinstance.html\n",
"\n",
"\n",
"Using an unpythonic loop\n",
"http://docs.quantifiedcode.com/python-anti-patterns/readability/using_an_unpythonic_loop.html\n",
"\n",
"\n",
"Using CamelCase in function names\n",
"http://docs.quantifiedcode.com/python-anti-patterns/readability/using_camelcase_in_function_names.html\n",
"\n",
"\n",
"...and many more, be sure to explore python-anti-patterns web site."
]
}
],
"metadata": {
"celltoolbar": "Slideshow",
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}