Advertisement
g7ad1at0r

dice.py

May 24th, 2022
1,020
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2.  
  3. class Dice:
  4.    
  5.     def __init__(self, name):
  6.         self.name = name
  7.    
  8.     def roll(self):
  9.         value = random.randint(1,6)
  10.         return value
  11.  
  12. dice1 = Dice("A")  
  13. dice2 = Dice("B")
  14. dice3 = Dice("C")
  15. dice4 = Dice("D")
  16. dice5 = Dice("E")
  17.  
  18. dices =[]
  19.  
  20. count = 0
  21.  
  22. for i in range(100):
  23.     print("***********")
  24.     dices =[dice1.roll(), dice2.roll(), dice3.roll(), dice4.roll(), dice5.roll()]
  25.     print(dices)
  26.     result = all(x == dices[0] for x in dices)
  27.     if result:
  28.         print("                       <<<< YAHTZEE <<<<")
  29.         count += 1
  30.  
  31. print(f"\n#########\n{count} yahtzee(s)")
Advertisement
RAW Paste Data Copied
Advertisement