Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. import random
  2. sim=100000
  3. total=0
  4. legal=0
  5. for i in range(sim):
  6. sesir=random.randint(1,3)
  7. kugla=random.randint(1,10)
  8. crvena=False
  9. if sesir==1 and kugla<4:
  10. crvena=True
  11. if sesir==2 and kugla<9:
  12. crvena=True
  13. if sesir==3 and kugla<5:
  14. crvena=True
  15. if crvena==True and sesir==3:
  16. legal+=1
  17. total+=1
  18. elif crvena==True:
  19. total+=1
  20.  
  21.  
  22. res=(legal/total)
  23. print(format(res,'.4f'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement