version super-naive de l'ordi devinant un numéro
This commit is contained in:
parent
651b23f462
commit
b9f2238bb6
1 changed files with 39 additions and 0 deletions
39
src/devine_ordi_0.py
Normal file
39
src/devine_ordi_0.py
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
#encoding: utf-8
|
||||||
|
|
||||||
|
import random
|
||||||
|
|
||||||
|
min=0
|
||||||
|
max=10
|
||||||
|
print("Pense à un nombre entre",min,"et",max)
|
||||||
|
|
||||||
|
essais = 4
|
||||||
|
|
||||||
|
def devine_entre(nb_min,nb_max):
|
||||||
|
if nb_min == nb_max:
|
||||||
|
print("Tu as triché !")
|
||||||
|
return random.randint(nb_min,nb_max)
|
||||||
|
|
||||||
|
|
||||||
|
while essais > 0:
|
||||||
|
devine = devine_entre(min,max)
|
||||||
|
|
||||||
|
print("Je pense au nombre",devine,", est-il:")
|
||||||
|
print("0: trop petit ?")
|
||||||
|
print("1: trop grand ?")
|
||||||
|
print("2: le bon numéro ?")
|
||||||
|
reponse = int( input() )
|
||||||
|
|
||||||
|
if reponse == 0:
|
||||||
|
min = min + 1
|
||||||
|
|
||||||
|
elif reponse == 1:
|
||||||
|
max = max - 1
|
||||||
|
|
||||||
|
elif reponse == 2:
|
||||||
|
print("Enfin !")
|
||||||
|
break
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("Tu dois répondre par 1, 2 ou 3 !")
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue