Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import random as r
  2.  
  3. class Dodewuerfel(object):
  4. def __init__(self):
  5. self.augenZahl = ()
  6.  
  7. def würfeln(self):
  8. gewuerfelteZahl = r.randint(1,12)
  9. self.augenZahl = (gewuerfelteZahl)
  10.  
  11. def einSpiel():
  12. counter = 0
  13. gesamt = 0
  14. würfel = Dodewuerfel()
  15. while gesamt < 21:
  16. counter = counter+1
  17. würfel.würfeln()
  18. gesamt = gesamt + würfel.augenZahl
  19.  
  20. return counter
  21.  
  22.  
  23.  
  24.  
  25. würfel=Dodewuerfel()
  26. anzahl = 10
  27. anzahlZumRechnen = anzahl
  28. counter = 0
  29. counterGesamt = 0
  30.  
  31. while anzahl > 0:
  32. counter = einSpiel()
  33. counterGesamt = counterGesamt + counter
  34. anzahl = anzahl - 1
  35.  
  36.  
  37. schnitt = counterGesamt / anzahlZumRechnen
  38.  
  39. print(schnitt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement