1 + 3 %%html

Cette cellule contient du HTML !

Remarquez la clef magique %%html.

a = 1 a type(a) a = "toto" a type(a) a + 1 a.upper() b = a.upper() b a a = 1 b = 2 a = 2 a = "toto" a == 'toto' a[1] type(a[1]) a = "tot o" a = """ Mignonne, allons voir si la rose Qui ce matin avoit desclose Sa robe de pourpre au Soleil, """ a print a "La reponse est %d" % 42 "La %s est %d" % ("question", 24) a = 1 a == 1.0 a = 1000000 a * a * a * a * a * a a**6 True == (not False) True and False True or False a = ["a", "b", "c"] a[1] len(a) a[2] = "d" a a[3] a[3] = "e" a.append("e") a " ~~=> ".join(a) a = { "couleur": "rouge", "forme": "rond"} a len(a) a["couleur"] a["taille"] = "grand" a if 1 + 1 == 2 and 1 - 1 > 0: a = 10 print "faux" elif 3 + 4 == 7: a = 3 print "yes" else: a = 4 print "no" a i = 0 while i < 10: print i i += 1 a = ["a", "b", "c"] for x in a: print x range(10) for i in range(10): print i def ma_fonction(x, y): c = 2*x return c + y ma_fonction(2, 3) def fct(x, y=3, z=10): return x + y + z fct(2), fct(2, 4), fct(2, 4, 1), fct(2, z=3) import numpy from pylab import imshow, show from timeit import default_timer as timer %pylab inline def mandel(x, y, max_iters): """ Given the real and imaginary parts of a complex number, determine if it is a candidate for membership in the Mandelbrot set given a fixed number of iterations. """ c = complex(x, y) z = 0.0j for i in range(max_iters): z = z*z + c if (z.real*z.real + z.imag*z.imag) >= 4: return i return max_iters def create_fractal(min_x, max_x, min_y, max_y, image, iters): height = image.shape[0] width = image.shape[1] pixel_size_x = (max_x - min_x) / width pixel_size_y = (max_y - min_y) / height for x in range(width): real = min_x + x * pixel_size_x for y in range(height): imag = min_y + y * pixel_size_y color = mandel(real, imag, iters) image[y, x] = color image = numpy.zeros((1024, 1536), dtype = numpy.uint8) start = timer() create_fractal(-2.0, 1.0, -1.0, 1.0, image, 20) dt = timer() - start print "Mandelbrot created in %f s" % dt imshow(image) show()