 # Untitled

a guest
Oct 3rd, 2021
118
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import math, random
2.
3. #RUN CONDITIONAL ON 60% WINNING MARGIN
4. elections = 10000000
5. voters = 100
6. loses = ties = wins = 0
7. for j in range(elections):
8. myvote = random.choice([-1,1])
10. for i in range(voters):
14. print('myvote:', myvote)
15. if votes * myvote < 0:
16. #print('LOST')
17. loses = loses + 1
18. if votes * myvote == 0:
19. #print('TIED')
20. ties = ties + 1
21. if votes * myvote > 0:
22. #print('WON')
23. wins = wins + 1
24. print('elections',elections)
25. print('loses',loses)
26. print('ties',ties)
27. print('wins',wins)
28.
29.
30.
31.
32. #RUN AS A RANDOM VOTER SAMPLE
33. ##elections = 100000
34. ##voters = 1000
35. ##loses = ties = wins = 0
36. ##for j in range(elections):
38. ## for i in range(voters):
40. ## myvote = random.randrange(-voters, voters)
42. ## #print('myvote:', myvote)
44. ## #print('LOST')
45. ## loses = loses + 1
46. ## if votes == 0:
47. ## #print('TIED')
48. ## ties = ties + 1
50. ## #print('WON')
51. ## wins = wins + 1
52. ##print('elections',elections)
53. ##print('loses',loses)
54. ##print('ties',ties)
55. ##print('wins',wins)
56.
57.
58.
59.
60.
61. #REGULAR RUN
62. ##elections = 100000
63. ##voters = 1000
64. ##loses = ties = wins = 0
65. ##for j in range(elections):
66. ## myvote = random.choice([-1,1])
68. ## for i in range(voters):
71. ## #print('myvote:', myvote)
72. ## if votes * myvote < 0:
73. ## #print('LOST')
74. ## loses = loses + 1
75. ## if votes * myvote == 0:
76. ## #print('TIED')
77. ## ties = ties + 1
78. ## if votes * myvote > 0:
79. ## #print('WON')
80. ## wins = wins + 1
81. ##print('elections',elections)
82. ##print('loses',loses)
83. ##print('ties',ties)
84. ##print('wins',wins)
RAW Paste Data