Bonjour voici mon code du jeux Nombre Aléatoire entre 1 et 100 en python 3.6 en français et anglais.Essayez le :
import random
Var=random.randint(1,100)
Com=1
Langue=input("What's your language? >>> " )
if(Langue.lower()=="français" ) or (Langue.lower()=="french" ):
while (1):
try:
Value=int(input("Tapez un nombre entre 1 et 100 >>> " ))
except ValueError:
print("Un nombre" )
break
if (Value>100) or (Value<=0):
print("Entre 1 et 100" )
exit()
if (Value>Var):
print("Trop grand" )
if (Value<Var):
print("Trop petit" )
if (Value==Var):
print("Bravo vous avez gagné" )
print("Vos tentatives =",Com)
Name=input("Rejouez? Oui/Non >>> " )
Name=Name.lower()
if (Name=="non" ) or (Name=="nan" ):
break
if (Name=="oui" ):
Var=random.randint(1,100)#j'ai fais ça car
Com=0 #Si je relance juste la boucle ça gardera
else: #Var
print("ERROR" )
exit()
Com+=1
if (Com==10):
print("Le nombre était",Var)
print("Vos tentatives =",Com)
Name=input("Rejouez? Oui/Non >>> " )
Name=Name.lower()
if (Name=="non" ) or (Name=="nan" ):
exit()
if (Name=="oui" ):
Var=random.randint(1,100)
Com=0
else:
print("ERROR" )
exit()
if (Langue.lower()=="english" ):
while (1):
try:
Value=int(input("Write a number between 1 and 100 >>> " ))
except ValueError:
print("A number" )
break
if (Value>100) or (Value<=0):
print("Between 1 and 100" )
exit()
if (Value>Var):
print("Too big" )
if (Value<Var):
print("Too small" )
if (Value==Var):
print("Congratulations you won" )
print("Your attemps =",Com)
Name=input("Try again? Yes/No >>> " )
Name=Name.lower()
if (Name=="no" ):
exit()
if (Name=="yes" ):
Var=random.randint(1,10)
Com=0
else:
print("ERROR" )
exit()
Com+=1
if (Com==10):
print("The number was",Var)
print("Your attemps =",Com)
Name=input("Try again? Yes/No >>> " )
Name=Name.lower()
if (Name=="no" ):
break
if (Name=="yes" ):
Var=random.randint(1,100)
Com=0
else:
print("ERROR" )
exit()
else:
print("French and english only available" )
Si vous voulez le modifier envoyer moi le code merci d'avance ^^