print("Hello World")
x = 1
y = x + 2
print x, y
import numpy as np
v = np.zeros(3)
M = np.ones((3,4))
A = np.array([[1,2,3],[4,5,6]])
print "v\n", v
print "M\n", M
print "A\n", A
You can also work with sub-matrices in a similar fashion as in MatLab, but starting with index 0:
print A
print "the first column of A:", A[:,0]
print "the first row of A:", A[0,:]
x = np.arange(10)
print x
y = np.random.uniform(size=10) # note the named argument here. The 1st (default) arguments are 0 and 1.
y # last element in cell is printed automatically
This is a library used to plot graphs conveniently directly from Python. Many graph types are supported.
import matplotlib.pyplot as plt
from IPython.display import HTML
HTML('<iframe src=http://matplotlib.org/gallery.html width=700 height=350></iframe>')
plt.plot(x, y)
plt.title("Sample Plot")
plt.xlabel("x label")
plt.ylabel("y label");
plt.scatter(x, y, s=100) # press TAB after opening parenthesis to see help on `scatter`;
from IPython.display import HTML
HTML('<iframe src=http://scikit-learn.sourceforge.net/dev/auto_examples/index.html width=900 height=350></iframe>')
Easy-to use machine-learning with many examples and documentation.