Variables#

En python, il est possible de stocker de l’information dans des variables

a = 3
a
a + 1
b = 5
if a > b:
    print("le max est ", a)
else:
    print("le max est ", b)

Dans le labyrinthe suivant, la position de la porte est stockée dans deux variables : \(x\) et \(y\)

from laby.global_fr import *
from random import randint

x = randint(0,9)
y = randint(1,9)

carte = "o "*12 + "\n"
for i in range(9):
    carte += "o "
    for j in range(10):
        if x == j and y == (9 - i):
            carte += "x "
        else:
            carte += ". "
    carte += "o\n"
carte+= "o → " + ". " * 9 + "o \n"
carte+= "o "*12 + "\n"
Laby(carte = carte)

La position de la porte est donnée par

x
y

Comment sortir du labyrinthe ?