print 'Hello World' print '\n' # if you want to print to multiple lines, print 'Hello', '\n', 'World' a = 10 print 'the value of a is', a print '\n' # if you want to specify the # data type to be used #print 'the value of a is %(f)', a print 'the value of 1/2 is', 1/2 print 'n' print 'the value of 1/2 is', 1./2 import numpy as np import matplotlib.pyplot as plt plt.plot() import sys import numpy import scipy #import numpy as np import matplotlib #import matplotlib.pyplot as plt import IPython # similar to # #include in c print 'the version of python we are using is',(sys.version) print 'the version of numpy is ', numpy.version.version, '\n',\ 'the version of scipy is', scipy.version.version, '\n',\ 'the version of matplotlib is ', matplotlib.__version__ print 'the version of IPython being used is', IPython.__version__ print 'hello world' # it's that simple var = 4 print 'var =', var # inorder to print var temp = 0 for i in range(10): temp += 1 print 'sum of first ten integers = ', temp # note that in python, the loop starts from 0 and ends at n-1 # in the above mentioned case, the loop goes from 0 to 9! # operations involving arrays can make use of len(array) array = [1,2,3,4] for i in xrange(len(array)): print array[i] import matplotlib.pyplot as plt # as mentioned above, # library.module.submodule.fuction(arg1, arg2) # is the way in which we can access the various functions in python libraries # in this case, the plotting feature is in matplotlib.pyplot # and instead of having to write matplotlib.pyplot everytime # we refer to it using plt instead %matplotlib inline # is why i love ipython-notebooks # we can embed plots between the code!# plt.plot(array,'o') # plt.show() # if you're not working on ipython, # you will have to run plt.show() # to display the plot print numpy.array(['foo','bar',1,2,3]), ['foo','bar',1,2,3]