ateliers:robotique:echange_de_code
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
ateliers:robotique:echange_de_code [2024/01/23 17:06] – 2a02:a03f:c66a:ab00:b400:931d:a04d:3f7b | ateliers:robotique:echange_de_code [2025/02/17 18:49] (Version actuelle) – portouverte | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== Ici on échange nos microdes ====== | ====== Ici on échange nos microdes ====== | ||
+ | |||
+ | < | ||
+ | < | ||
+ | $(document).ready(function() { | ||
+ | const $subMenu = $(' | ||
+ | $subMenu.hide(); | ||
+ | |||
+ | $(" | ||
+ | event.preventDefault(); | ||
+ | $subMenu.slideToggle(50); | ||
+ | $(this).find(" | ||
+ | }); | ||
+ | |||
+ | // Gestion de l' | ||
+ | $("# | ||
+ | $subMenu.slideUp(50); | ||
+ | $(" | ||
+ | }); | ||
+ | }); | ||
+ | </ | ||
+ | | ||
+ | | ||
+ | ===== CSS ===== | ||
+ | /******** SUB MENU ********/ | ||
+ | .sub-menu ul { | ||
+ | display: none; | ||
+ | position: absolute; | ||
+ | border-radius: | ||
+ | z-index: 100; | ||
+ | left: 200px; | ||
+ | } | ||
+ | |||
+ | .sub-menu li { | ||
+ | display: block; | ||
+ | padding: 10px; | ||
+ | color: #333; | ||
+ | text-decoration: | ||
+ | } | ||
+ | .sub-menu li input { | ||
+ | color: #333; | ||
+ | width: 20px; | ||
+ | height: 20px; | ||
+ | left: -35px; | ||
+ | position: absolute; | ||
+ | transform: rotate(-45deg); | ||
+ | top: 40px; | ||
+ | } | ||
+ | .sub-menu li label { | ||
+ | color: white; | ||
+ | position: absolute; | ||
+ | left: -25px; | ||
+ | font-size: 1.3rem; | ||
+ | transform: rotate(-45deg); | ||
+ | left: 33px; | ||
+ | top: -10px; | ||
+ | } | ||
+ | |||
+ | .sub-menu li:hover { | ||
+ | background-color: | ||
+ | } | ||
+ | |||
+ | / | ||
+ | | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | git clone https:// | ||
+ | |||
+ | |||
+ | cd interactive-ink-examples-uwp | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
<code python> | <code python> | ||
+ | import random | ||
+ | import tkinter as tk | ||
+ | from tkinter import StringVar, Entry, Button, PhotoImage | ||
- | lQCeU6z6GyNqnyyXXjMy826FrlX2 | + | |
+ | # Définir la fonction choisir_mot qui choisit un mot aléatoire | ||
+ | def choisir_mot(): | ||
+ | mots = [" | ||
+ | return random.choice(mots) | ||
+ | |||
+ | |||
+ | # Définir la fonction afficher_mot qui affiche le mot à deviner avec les lettres trouvées | ||
+ | def afficher_mot(mot, | ||
+ | affichage = "" | ||
+ | for lettre in mot: | ||
+ | if lettre in lettres_trouvees: | ||
+ | affichage += lettre | ||
+ | else: | ||
+ | affichage += " | ||
+ | return affichage | ||
+ | |||
+ | |||
+ | # Définir la fonction pendu qui permet de jouer au jeu du pendu avec une interface graphique | ||
+ | def pendu(): | ||
+ | # Choisir un mot aléatoire | ||
+ | mot_a_deviner = choisir_mot() | ||
+ | |||
+ | # Initialiser les variables de jeu | ||
+ | lettres_trouvees = [] | ||
+ | tentatives_max = 6 | ||
+ | tentatives = 0 | ||
+ | |||
+ | # Créer une fenêtre Tkinter | ||
+ | fenetre = tk.Tk() | ||
+ | fenetre.geometry(" | ||
+ | fenetre.title(" | ||
+ | |||
+ | # Créer les éléments graphiques | ||
+ | label_mot = tk.Label(fenetre, | ||
+ | label_mot.pack() | ||
+ | |||
+ | entry_lettre = tk.Entry(fenetre) | ||
+ | entry_lettre.pack() | ||
+ | |||
+ | label_tentatives = tk.Label(fenetre, | ||
+ | label_tentatives.pack() | ||
+ | |||
+ | # Fonction pour vérifier la lettre choisie | ||
+ | def verifier_lettre(): | ||
+ | nonlocal tentatives | ||
+ | lettre_choisie = entry_lettre.get() | ||
+ | entry_lettre.delete(0, | ||
+ | |||
+ | if lettre_choisie in lettres_trouvees: | ||
+ | label_tentatives.config(text=" | ||
+ | elif lettre_choisie in mot_a_deviner: | ||
+ | lettres_trouvees.append(lettre_choisie) | ||
+ | label_mot.config(text=afficher_mot(mot_a_deviner, | ||
+ | |||
+ | if " | ||
+ | label_tentatives.config(text=" | ||
+ | else: | ||
+ | tentatives += 1 | ||
+ | label_tentatives.config(text=" | ||
+ | if tentatives == tentatives_max: | ||
+ | label_tentatives.config( | ||
+ | text=" | ||
+ | |||
+ | # Créer le bouton pour valider la lettre choisie | ||
+ | btn_valider = tk.Button(fenetre, | ||
+ | btn_valider.pack() | ||
+ | |||
+ | fenetre.mainloop() | ||
+ | # Appeler la fonction pendu pour jouer au jeu | ||
+ | pendu() | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | <code python> | ||
+ | code de Tom | ||
+ | |||
+ | import random | ||
+ | |||
+ | def choisir_mot(): | ||
+ | mots = [" | ||
+ | return random.choice(mots) | ||
+ | |||
+ | |||
+ | def afficher_mot(mot, | ||
+ | affichage = "" | ||
+ | for lettre in mot: | ||
+ | if lettre in lettres_trouvees: | ||
+ | affichage += lettre | ||
+ | else: | ||
+ | affichage += " | ||
+ | return affichage | ||
+ | |||
+ | def pendu(): | ||
+ | mot_a_deviner = choisir_mot() | ||
+ | |||
+ | #creation du TABLEAU appele lettre trouvees | ||
+ | lettres_trouvees =[] | ||
+ | |||
+ | tentatives_max = 6 | ||
+ | tentatives = 0 | ||
+ | |||
+ | print(" | ||
+ | |||
+ | # while = tant que... | ||
+ | while tentatives <= tentatives_max: | ||
+ | lettre_choisie = input(" | ||
+ | |||
+ | if lettre_choisie in lettres_trouvees : | ||
+ | print ("tu as deja tape cette lettre gros noob. reesaie sal noob." | ||
+ | continue | ||
+ | |||
+ | if lettre_choisie in mot_a_deviner: | ||
+ | lettres_trouvees.append(lettre_choisie) | ||
+ | mot_actuel = afficher_mot(mot_a_deviner, | ||
+ | print(mot_actuel) | ||
+ | |||
+ | if " | ||
+ | print(" | ||
+ | break | ||
+ | |||
+ | else: | ||
+ | tentatives += 1 | ||
+ | print(" | ||
+ | |||
+ | if tentatives == tentatives_max: | ||
+ | print(" | ||
+ | pendu() | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | <code python> | ||
# Importer le module random | # Importer le module random | ||
import random | import random | ||
Ligne 24: | Ligne 236: | ||
# Définir la fonction pendu qui permet de jouer au jeu du pendu | # Définir la fonction pendu qui permet de jouer au jeu du pendu | ||
def pendu(): | def pendu(): | ||
+ | # Choisir un mot aléatoire | ||
mot_a_deviner = choisir_mot() | mot_a_deviner = choisir_mot() | ||
+ | # Initialiser les variables de jeu | ||
lettres_trouvees = [] | lettres_trouvees = [] | ||
tentatives_max = 6 | tentatives_max = 6 | ||
tentatives = 0 | tentatives = 0 | ||
+ | # Afficher un message de bienvenue | ||
print(" | print(" | ||
- | while tentatives <= tentatives_max: | + | |
+ | | ||
# Demander à l' | # Demander à l' | ||
lettre_choisie = input(" | lettre_choisie = input(" | ||
Ligne 43: | Ligne 259: | ||
# Vérifier si la lettre est dans le mot à deviner | # Vérifier si la lettre est dans le mot à deviner | ||
if lettre_choisie in mot_a_deviner: | if lettre_choisie in mot_a_deviner: | ||
+ | lettres_trouvees.append(lettre_choisie) | ||
+ | mot_actuel = afficher_mot(mot_a_deviner, | ||
+ | print(mot_actuel) | ||
- | print(" | + | |
- | | + | if " |
+ | | ||
+ | break | ||
else: | else: | ||
tentatives += 1 | tentatives += 1 | ||
- | print(" | + | print(" |
+ | |||
+ | # Afficher un message de fin de jeu | ||
+ | if tentatives == tentatives_max: | ||
+ | print(" | ||
+ | # Appeler la fonction pendu pour jouer au jeu | ||
+ | pendu() | ||
</ | </ | ||
ateliers/robotique/echange_de_code.1706026014.txt.gz · Dernière modification : 2024/01/23 17:06 de 2a02:a03f:c66a:ab00:b400:931d:a04d:3f7b