Différences entre les versions de « Utilisateur:Selim »

De {}
Aller à la navigation Aller à la recherche
Ligne 1 : Ligne 1 :
 +
=Quelques petits codes huhu=
 +
 +
==code du lundi 11 oct 2021==
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
  
Ligne 16 : Ligne 19 :
 
else:
 
else:
 
     print("intéressant")
 
     print("intéressant")
 +
</syntaxhighlight>
 +
 +
==code du lundi 18 oct 2021==
 +
<syntaxhighlight lang="python">
 +
import random
 +
 +
animaux = ["lapin", "chat", "mille-pattes", "serpent", "banquier", "radis", "loup"]
 +
 +
memoire = []
  
 +
i = 0
 +
while i < 10:
 +
    indice = 0
 +
    indice1 = random.randint(0, len(animaux))
 +
    indice2 = random.randint(0, len(animaux))
 +
    if indice1 != indice2:
 +
        while (f"{indice1}-{indice2}") != memoire[indice]:
 +
            indice = indice + 1
 +
            if indice == len(memoire):
 +
                memoire.apend(f"{indice1}-{indice2}")
 +
                print(f"le {animaux[indice1]} mange le {animaux[indice2]}")
 +
                print("miam miam")
 +
                i = i + 1
 
</syntaxhighlight>
 
</syntaxhighlight>

Version du 18 octobre 2021 à 08:53

Quelques petits codes huhu

code du lundi 11 oct 2021

print("combien de doigts as-tu?")
doigts = input("j'en ai ")
doigts = int(doigts)
if doigts == 10:
    print("original pour un poisson")
elif doigts == 0:
    print("comme moi")
    print("...")
    print("...")
    print("...")
    print("mais comment m'as tu répondu?")
elif doigts == 20:
    print("tu as des doigts de pieds, c'est bien")
else:
    print("intéressant")

code du lundi 18 oct 2021

import random

animaux = ["lapin", "chat", "mille-pattes", "serpent", "banquier", "radis", "loup"]

memoire = []

i = 0
while i < 10:
    indice = 0
    indice1 = random.randint(0, len(animaux))
    indice2 = random.randint(0, len(animaux))
    if indice1 != indice2:
        while (f"{indice1}-{indice2}") != memoire[indice]:
            indice = indice + 1
            if indice == len(memoire):
                memoire.apend(f"{indice1}-{indice2}") 
                print(f"le {animaux[indice1]} mange le {animaux[indice2]}")
                print("miam miam")
                i = i + 1