In this tutorial notebook, you will learn how to do programming in python and Jupyter (formerly named as ipython). Syntax of python is cosidered as "clean" compared to other languages.
Open a new python notebook, try to copy
and paste
the following codes to play with. The following codes show an example of a woring python code that calculate the
The Jupyter notebook is getting more attentions in the natural Science field in the past years. The development of jupyter notebook makes it more advance and stable. This is an article about
http://www.nature.com/news/interactive-notebooks-sharing-the-code-1.16261
SHIFT+ENTER
on your keyboard or press the play button () in the toolbar above.Hello World!
statementprint("Hello World!")
SHIFT+ENTER
on your keyboard!
In [ ]:
PROGRAM HELLO
WRITE (*,100)
STOP
100 FORMAT (' Hello World! ' /)
END
(print "Hello World!")
#include <iostream.h>
main()
{
cout << "Hello World!" << endl;
return 0;
}
class HelloWorld {
static public void main( String args[] ) {
System.out.println( "Hello World!" );
}
}
disp('Hello World!');
document.write('Hello World!')
In [2]:
print "Hello", "World!"
In [3]:
print "Tips 3: Use \ to escape an characters like \""
print "Tips 4: Use \\n \n to make a newline character"
print '''Tips 5: Use three \' to
make
multiple
line
'''
Any command starts with %
are magic command in ipython notebook. These %
command can only be used in ipython instant. A full list of magic command can be found here:
http://ipython.readthedocs.io/en/stable/interactive/magics.html.
These commands are particularly useful in developing and debugging your program.
Python is rich in library. Use expression like
import xxxxxxx
or
from xxxxxxx import yyyyyy
to import library provided that you know the name of your library xxxxxx and objects yyyyyyy in the library xxxxxxx.
Package is not loaded at the beginning, you need to import it before using it.
In [4]:
time.sleep(0.5);
print "Too bad"
In [5]:
import time
time.sleep(0.5);
print "Now its work"
In [6]:
print "We delete the time object to unload it from memory"
del time
time.sleep(0.5);
Sometimes you may need to write down some notes for yourself. The Jupyter notebook provides convenient ways for you to describe the notes in a Markdown
mark-up language. To learn this language, you can look at the following page: https://guides.github.com/features/mastering-markdown/ . GitHub utilizes Markdown extensively.
To change the purpose of the cell, you can look up a widget like this:
and select Markdown
In [ ]: