Carotte

papier 2*

Nov 6th, 2020
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. # jeu pierre, papier, ciseaux
  2. # l'ordinateur joue au hasard
  3.  
  4. from random import randint
  5.  
  6. def ecrire(nombre):
  7. if nombre == 1:
  8. print("pierre",end=" ")
  9. elif nombre ==2:
  10. print("papier",end=" ")
  11. else :
  12. print("ciseaux",end=" ")
  13.  
  14. def augmenter_scores(mon_coup,ton_coup,mon_score,ton_score):
  15. mon_nouveau_score = mon_score
  16. ton_nouveau_score = ton_score
  17. if mon_coup == 1 and ton_coup == 2:
  18. ton_nouveau_score += 1
  19. elif mon_coup == 2 and ton_coup == 1:
  20. mon_nouveau_score += 1
  21. elif mon_coup == 1 and ton_coup == 3:
  22. mon_nouveau_score += 1
  23. elif mon_coup == 3 and ton_coup == 1:
  24. ton_nouveau_score += 1
  25. elif mon_coup == 3 and ton_coup == 2:
  26. mon_nouveau_score += 1
  27. elif mon_coup == 2 and ton_coup == 3:
  28. ton_nouveau_score += 1
  29. return mon_nouveau_score, ton_nouveau_score
  30.  
  31. ton_score = 0
  32. mon_score = 0
  33. fin = 5
  34. print("Pierre-papier-ciseaux. Le premier à",fin,"a gagné !")
  35. no_manche = 0
  36. while mon_score < fin and ton_score < fin:
  37. ton_coup = int(input("1 : pierre, 2 : papier, 3 : ciseaux ? "))
  38. while ton_coup < 1 or ton_coup > 3:
  39. ton_coup =int(input("1 : pierre, 2 : papier, 3 : ciseaux ? "))
  40. print("Vous montrez",end=" ")
  41. ecrire(ton_coup)
  42. mon_coup = randint(1,3)
  43. print("- Je montre",end=" ")
  44. ecrire(mon_coup)
  45. print() # aller à la ligne
  46. mon_score,ton_score=augmenter_scores(mon_coup,ton_coup,mon_score,ton_score)
  47. print("vous",ton_score," moi",mon_score)
  48.  
  49.  
  50.  
Add Comment
Please, Sign In to add comment