sstaworko@a5114-01:~$ python Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> l = [1, 2, 3, 4] >>> l [1, 2, 3, 4] >>> l [1, 2, 3, 4] >>> len(l) 4 >>> l.append(5) >>> l [1, 2, 3, 4, 5] >>> x = l.pop() >>> x 5 >>> l [1, 2, 3, 4] >>> l.insert(0,10) >>> l [10, 1, 2, 3, 4] >>> l[0] 10 >>> l[1] 1 >>> l[2] 2 >>> l[3] 3 >>> l[4] 4 >>> l[5] Traceback (most recent call last): File "", line 1, in IndexError: list index out of range >>> d = {'a' : 1, 'b' : 2 } >>> d {'a': 1, 'b': 2} >>> d['a'] 1 >>> d['b'] 2 >>> d['a'] = 20 >>> d {'a': 20, 'b': 2} >>> d['c'] = 40 >>> d {'a': 20, 'c': 40, 'b': 2} >>> t = (1,2,3) >>> len(t) 3 >>> t[0] 1 >>> t[1] 2 >>> t[2] 3 >>> t[1] = 20 Traceback (most recent call last): File "", line 1, in TypeError: 'tuple' object does not support item assignment >>> t (1, 2, 3) >>> t = (4,5,6) >>> t (4, 5, 6) >>> l [10, 1, 2, 3, 4] >>> l[1] = 20 >>> l [10, 20, 2, 3, 4] >>> l [10, 20, 2, 3, 4] >>> k = l >>> k[1] = 0 >>> k [10, 0, 2, 3, 4] >>> l [10, 0, 2, 3, 4] >>> k = l[:] >>> l [10, 0, 2, 3, 4] >>> k [10, 0, 2, 3, 4] >>> k[1] = 20 >>> k [10, 20, 2, 3, 4] >>> l [10, 0, 2, 3, 4] >>> range(1,10) [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> w = [1, 2, 4, 7, 9] >>> sum = 0 >>> for val in w: ... sum = sum + w ... Traceback (most recent call last): File "", line 2, in TypeError: unsupported operand type(s) for +: 'int' and 'list' >>> sum = 0 >>> for val in w: ... sum = sum + val ... >>> sum 23 >>> w [1, 2, 4, 7, 9] >>> i = 1 >>> i == 2 False >>> i != 2 True >>> l [10, 0, 2, 3, 4] >>> l != [] True >>> not True False >>> True and True True >>> True and False False >>> False and False False >>> False and True False >>> True or True True >>> True or False True >>> False or True True >>> False or False False >>> (1,2) (1, 2) >>> pos1 = (1,2) >>> pos2 = (3,4) >>> pos1 (1, 2) >>> pos2 (3, 4) >>> positions = [pos1,pos2] >>> positions [(1, 2), (3, 4)] >>> for (i,j) in positions: ... print "Position colonne =",i," et ligne =",j ... Position colonne = 1 et ligne = 2 Position colonne = 3 et ligne = 4