import numpy as np sl=[np.sin(x) for x in np.arange(0,10,.1)] import matplotlib.pyplot as plt plt.plot(sl) plt.show() %matplotlib inline #If you remove the semicolon and it is the last line, the next line will print out the values [[np.sin(x)*np.cos(y) for x in np.arange(0,1,.1)] for y in np.arange(0,1,.1)]; #but it won't if you assign a variable name to the array sl2=[[np.sin(x)*np.cos(y) for x in np.arange(0,1,.1)] for y in np.arange(0,1,.1)]; #make a vector with 5 rows and 6 columns sl3=np.array([[x+y*6 for x in np.arange(0,6,1)] for y in np.arange(0,5,1)]) #what happens if you don't use np.array() in the above line? print np.array(sl3),'\n\n(#rows, #columns)=',np.shape(sl3),"# elements:",np.size(sl3) #note that unlike Mathematica and Matlab (but like C), indexing starts with 0 #first row sl3[0] #first column sl3[:,0] #Try accessing the element in the 3rd row, 4th column. It isn't sl3[3,4]| #Get the first 2 elements of sl. It isn't sl[0:1]. #Now get the submatrix 3rd and 4th row, 4th through 6th columns sl3[2:4,3:6] def f(x,y): return([[np.sin(3*x)*np.cos(4*y) for x in np.arange(0,1,.1)] for y in np.arange(0,1,.1)]) #Visualize f(x,y) using imshow() import matplotlib.cm as cm n = 10 x = np.linspace(-3,3,4*n) y = np.linspace(-3,3,3*n) X, Y = np.meshgrid(x,y) plt.imshow(f(X,Y),cmap = cm.Greys_r,origin='lower',interpolation='nearest');