#!/usr/bin/env python # coding: utf-8 # #GLACINDIA Workshop # ##Part 4: ~~IPython~~ Jupyter notebook # Nikolay Koldunov # # # koldunovn@gmail.com # In order to be productive you need comfortable environment, and this is what ~~IPython~~ Jupyter notebooks provide. This is your "lab book", where you can run the code, visualize data and write the text. # ###Code execution # In[1]: print('I love Python!!!!') # ### Text (Markdown) # IPython [website](http://ipython.org/). # # List: # # * [Python on Codeacademy](http://www.codecademy.com/tracks/python) # * [Google's Python Class](https://developers.google.com/edu/python/) # # Code: # # print('hello world') # # #### $\LaTeX$ equations # $$\int_0^\infty e^{-x^2} dx=\frac{\sqrt{\pi}}{2}$$ # $$ # F(x,y)=0 ~~\mbox{and}~~ # \left| \begin{array}{ccc} # F''_{xx} & F''_{xy} & F'_x \\ # F''_{yx} & F''_{yy} & F'_y \\ # F'_x & F'_y & 0 # \end{array}\right| = 0 # $$ # #### Plots # In[2]: import matplotlib.pylab as plt get_ipython().run_line_magic('matplotlib', 'inline') # In[4]: x = [1,2,3,4,5] plt.plot(x); # * [IPython website](http://ipython.org/) # * [Notebook gallery](https://github.com/ipython/ipython/wiki/A-gallery-of-interesting-IPython-Notebooks) # ## Run notebook # - Go to `start` menu # - Find Anaconda 32 folder # - run IPython notebook # ## Main IPyhton features # ### Getting help # You can use question mark in order to get help. To execute cell you have to press *Shift+Enter* # In[7]: get_ipython().show_usage() # Question mark after a function will open pager with documentation. Double question mark will show you source code of the function. # In[8]: get_ipython().run_line_magic('pinfo', 'plt.plot') # Press SHIFT+TAB after opening bracket in order to get help for the function (list of arguments, doc string). # In[ ]: range( # ## Magic functions # The magic function system provides a series of functions which allow you to # control the behavior of IPython itself, plus a lot of system-type # features. # Let's create some set of numbers using [range](http://docs.python.org/2/library/functions.html#range) command: # In[5]: range(10) # And find out how long does it take to run it with *%timeit* magic function: # In[6]: get_ipython().run_line_magic('timeit', 'range(10)') # Print all interactive variables (similar to Matlab function): # In[7]: get_ipython().run_line_magic('whos', '') # In[ ]: