test.py

Created by elodie-gamot

Created on June 09, 2022

1.35 KB

Flèche du haut pour passer au coup suivant


from turtle import *
from ion import *

def pendu(i):
  if i==1:
    penup()
    goto(-50,-110)
    pendown()
    setheading(0)
    forward(120)
    backward(50)
  if i==2:
    setheading(90)
    forward(180)
    left(90)
    forward(50)
  if i==3:
    circle(10)
  if i==4:
    penup()
    goto(-30,50)
    setheading(-90)
    pendown()
    forward(60)
  if i==5:
    penup()
    goto(-30,50)
    pendown()
    goto(-50,30)
    penup()
    goto(-30,50)
    pendown()
    goto(0,30)
  if i==6:
    penup()
    goto(-30,-10)
    pendown()
    goto(0,-40)
    penup()
    goto(-30,-10)
    pendown()
    goto(-50,-40)

def jeu():
  mot=""
  mot=input("Quel est le mot à deviner?")
  guess="_"*len(mot)
  erreur=0

  while (not(keydown(KEY_UP))):
    continue

  print("\n\n\n\n\n\n\n\n\n\n\n")

  while guess!=mot and erreur!=6:
    letter=input("Choisissez une lettre:")
    if letter in mot:
      print("Bravo, continuez !")
      guess=list(guess)
      position=([pos for pos, char in enumerate(mot) if char == letter])
      for number in position:
        guess[number]=letter
      guess=''.join(guess)
      print(guess)
    else:
      erreur+=1
      for k in range(1,erreur+1):
        pendu(k)
      hideturtle()

    while (not(keydown(KEY_UP))):
      continue
  
  if guess==mot:
    print("C'est gagné !!")
    
  if erreur==6:
    print("C'est perdu !!")

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.