XD blog

blog page

teaching


2013-04-06 Installation of module PyMC

Installing a Python module can lead you quite far especially if this one includes some fortran files. That's what happened when I tried to install PyMC. That's what I did for Python 3.3 but it does not mean it is the simplest way.

Then, use Python and try import pymc to see if it worked. After that oue hour I spent gathering all the necessary steps, I forgot why I wanted to do it... Just kidding, Scipy does not exist yet on Python 3.3 and I needed the function normcdf (or cdf).

2013-04-05 Apprendre à coder en Python : illustration

Je suis tombé sur un site très intéressant d'un point de vue pédagogique : PythonTutor. Il permet de représenter visuellement l'exécution pas à pas d'un programme comme celui-ci par exemple qui effectue un tri bulle :

l = [4, 6, 3, -2, 6, 9, 3]
for i in range(0, len(l)) :
    for j in range(0,len(l)-1) :
        if l[j] > l[j+1] :
            a      = l[j+1]
            l[j+1] = l[j]
            l[j]   = a
Le suivant permet de bien visualiser ce que fait Python lorsqu'il interprète une affectation, une copie, un tri :
l = [ [ 0, 1, 2 ], [ 4, 5, 6], [ -1, -2, -3 ] ]
m = l
n = list(l)
n.sort()
L'image qui suit est une copie d'écran du programme dans son état final.


more...

Xavier Dupré