Codes Download
Click here for codes

Note: 
1) For the code of Sierpinski Gasket, you need Python 2.6+ with scipy, numpy, matplotlib.
2) Most of the code is a rewrite of Brian Bockelman's, which in turn is a rewrite of M.Gibbons' code in Maple.
3) Since there are functions under the same name for different carpets, please make sure your working directory is the one you need so that the correct function is called.