Python on Windows

Option 1: Google Colaboratory

This is by far the preferred option. Go to google colaboratory to create an interactive python Jupyter notebook.

Option 2: WinPython and Spyder

If you need to run python locally on Windows, you can use an application called Spyder. Download WinPython and install on your PC. It may take a few minutes to download and install, because it is bundled with several Python packages

When you have installed WinPython, run the application called Spyder. This should bring up a window that looks like the following:

The panel on the right is your python script (similar to the program window in Matlab). Press the green arrow button to run the script. The output will appear in the panel on the lower right.

Python plotting example: sin(x)

Use the following code to plot a simple trigonometric function using WinPython:

import numpy
import pylab

X = numpy.linspace(0,1,100)
Y = numpy.sin(2*X*numpy.pi)


When the code executes you should see the plot appear in the output window. If you would like to save your figure to a particular location, you can change the "show" line to the following:

(The format of the output file will be automatically determined by the extension. If you call the file "myfile.pdf" it will export in pdf format.)

Python plotting example: singularity brackets

The following script illustrates one way to plot functions using singularity brackets by defining a function called "bracket".

import numpy

import pylab

def bracket(x,n):

return 0.5*(numpy.sign(x)+1)*(x**n)

L = 1

X = numpy.linspace(0,2,1000)

Y0 = bracket(X-L,0)

Y1 = bracket(X-L,1)

Y2 = bracket(X-L,2)





Running the script generates the following output: