@justinholman/

CoinFlipSim-01

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# import modules
import random

# initiate variables
simcount = 0
heads = 0

# Simulate flipping a coin repeatedly
for i in range(100) :
  simcount += 1
  rand1 = random.random()
  if rand1 >= 0.5 :
    heads += 1
  pct_heads = round(heads/simcount,4)
  print(pct_heads)

print("sim complete")