def robtom3_1(): from random import sample from matplotlib import pyplot as plt urne = {-1, 0, 1} x, y, sortie = 0, 0, 0 posisTomX = [0] ; posisTomY = [0] while y <= 1 and y >= -1 and x <= 9: n = sample(urne, 1) y = y + n[0] x = x + 1 posisTomX.append(x) posisTomY.append(y) if y == -2 or y == 2: message = "TOM est tombé\nà l'eau" else: message = "TOM a passé \nle pont" sortie = 1 plt.figure() plt.plot((0, 10), (-2, 2), ls = 'none') ; plt.xticks(range(11)) ; plt.yticks(range(-2, 3)) plt.fill((0, 10, 10, 0), (-1, -1, 1, 1), alpha = 0.3, color = 'green')