1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| import random
PIERRE = 0
FEUILLE = 1
CISEAUX = 2
TEXTES = ('PIERRE', 'FEUILLE', 'CISEAUX')
def bat(coup_1, coup_2):
return coup_1 == (coup_2 + 1) % 3
def resulat_manche():
if bat(coup_o, coup_j):
pt = -1
verbe = 'bat'
elif bat(coup_j, coup_o):
pt = 1
verbe = 'est battu par'
else:
pt = 0
verbe = "annule"
return pt, verbe
def score():
if score > 0:
print('Gagne')
elif score == 0:
print('Nul')
else:
print('Perdu')
def manche(score):
coup_o = random.randint(0, 2)
coup_j = int(input("Entrez votre choix: 0 pour Pierre,"
"\n 1 pour feuille,"
"\n, ou 2 pour Ciseaux: "))
(pt, verbe) = resulat_manche(coup_o, coup_j)
score += pt
print('{} {} {} : {}'.format(TEXTES[coup_o], verbe, TEXTES[coup_j], [score]))
return score
def jeu(nb_manches):
# realiser les nb de manches
random.seed(int(input("Entrez un nombre: ")))
score = 0
for i in range(nb_manches):
score = manche(score)
# afficher le resultat final
resultat_manche(score)
jeu(5) |
Partager