iPython notebook installation

iPython notebook installation

The IPython Notebook is an interactive computational environment for Python, in which you can combine code execution, rich text, mathematics, plots and rich media.

Here we tell you how to install and run iPython notebook on Ubuntu. You can read about Ubuntu VM installation here. If you are using our VM Ubuntu, you had already iPython notebook installed.

Simple installation.

  • In Ubuntu the install should be simple, using the repository version to find all dependencies. Just type in the Terminal:
    sudo apt-get install ipython-notebook
  • Run iPython notebook with command
ipython notebook --pylab inline

 

Anaconda installation.

For new users who want to install a full Python environment for scientific computing and data science, we suggest installing the Anaconda which provide IPython and all of its dependences as well as a complete set of open source packages for scientific computing and data science.

bash Anaconda-2.2.0-Linux-x86.sh
  • Update iPython to the current version using the Terminal
conda update conda
conda update ipython ipython-notebook ipython-qtconsole
  • Run iPython notebook with command
ipython notebook --pylab inline

 Start with iPython notebook.

  • After running iPython notebook in your browser appears the window with localhost:8888 address. Click “New notebook” to create your first notebook.
  • Let’s try to use iPython notebook as calculator. Type in empty line next commands and click “Run Cell” after each command.
(50-5*6)/4

sqrt(81)

price = 20
amount = 15
cost = price*amount
print cost

 

  • Let’s solve a more difficult problem, for example, linear equations. Here we can using additional package -  symbolic algebra package Sympy . 

For the first import this package with command:

from sympy import *
init_printing()

 Now create symbolic variables

var('n1 n2')

 
Create a list of equations using the symbolic variables

eqns = [
    Eq(100, n1 + n2),
    Eq(30, 0.7*n1 + 0.2*n2)
]

 

 Solve and display solution

soln = solve(eqns)
display(soln)

 

  • Now  let’s work with strings. Type and run
greeting = "Hello, World!"
print greeting

 

print "I said", greeting

 

For a groupping of similar items together  Python use a data type called lists.

Days  = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]

 

One of the most useful things you can do with lists is to iterate through them, i.e. to go through each element one at a time. To do this in Python, we use the for statement

for day in days:

    statement = "Today is " + day
    print statement

 

days [0:2]
days [-2:]


These were the first steps in python. Then you will find more interesting things. Enjoy the learning!

 

 

Comments 0

Add a new comment: