iPython - Day One with Project Jupyter

iPython

I recently came across a fun tool that is very helpful for learning Python, at least it has helped me a great deal.

Formerly known as iPython, the web-notebook is now known as Project Jupyter.

Project Jupyter

In more traditional uses of Jupyter, scientists graph and plot data using matplotlib and numpy.

Some basic examples from my day playing with the notebook.

In [ ]:

import time  
import sys  
for i in range(1, 6):  
  print(i)
  time.sleep(1.50)

Out [ ]: (time-sensitive output)
1
2
3
4
5

In [ ]: a nice list comprehension

[x**2 for x in range(1, 6)]

Out [ ]:
[1, 4, 9, 16, 25]

In [ ]: (playing with pi)

from math import pi  
[str(round(pi, i)) for i in range(1, 6)]

Out [ ]:
['3.1', '3.14', '3.142', '3.1416', '3.14159']

edit: from cool stuff to do with iPython!
In [ ]:

from numpy import *  
from matplotlib.pyplot import *

x  linspace(-1, 1, 100)  
y = (-3*x**4 + 6*x**2)  

Out [ ]:

<matplotlib.figure.Figure at 0x7777be0>  

I also just learned about Beaker.

Another very cool Data Scientist's Lab Notebook. Beaker has many dependencies and requires you to install additional languages. I suggest downloading the Electron version. Beaker supports dozens of languages, including Scala, R, C, Ruby, Python, Go and many, many more. Check them out.

edit: I am now using Anaconda as my default Python interpreter when using Jupyter. It includes all of the modules required to do some advanced math or plotting, scientific equations, etc.

Craig Derington

Espousing the virtues of Secular Humanism, Libertarianism, Free and Open Source Software, Linux, Ubuntu, Terminal Multiplexing, Docker, Python, Flask, Django, Go, MySQL, PostgreSQL, MongoDB and Git.

comments powered by Disqus