# import random library and set seed
import random
random.seed(123456)

# Step 1.
# Define a function which randomly draws a ball
# with an integer between 1 and 100 on it;
# then returns True if Player
# wins and returns False if House wins.
# Add a print statement to function to print random integer
# and test out function
# Add comment statements to function
#
def ballTest():
drawBall = random.randint(1,100)
if (drawBall >= 52):
return True
else:
return False
print (ballTest())

```
False
```

# Step 2.
# Create a function which simulates playing the game
# n_plays times; keep track of number of wins and losses
def multiDraw(n_plays, funds, bet):
wins = 0
losses = 0
for i in range(0,n_plays):
if (ballTest()==True):
funds+=bet
wins+=1
else:
funds-=bet
losses+=1
return [funds,wins,losses]

print (multiDraw(5,10000,100))

```
[10100, 3, 2]
```

totalWins = 0
totalLosses = 0
totalFunds = 0
outcomes = [0,0,0]
for i in range(100):
outcomes = multiDraw(5,10000,100)
totalFunds += outcomes[0]
totalWins += outcomes[1]
totalLosses += outcomes[2]
avgFunds = totalFunds/100
print (f'The average amount of funds left after 5 games: {avgFunds}')
disProbWin = totalWins/500
disProbLoss = 1-disProbWin
print (f'The discrete probability of winning is: {disProbWin}. The discrete probability of losing is {disProbLoss}')
disAmount = (100*disProbWin)-(100*disProbLoss)
print (f'The discrete expected value is {disAmount}')

```
The average amount of funds left after 5 games: 10024.0
The discrete probability of winning is: 0.524. The discrete probability of losing is 0.476
The discrete expected value is 4.800000000000011
```

#need to play more total games
games = 5
rounds = 1000000
totalGames = games*rounds
#call f(x)
outcomes = multiDraw(totalGames,10000,100)
totalFunds = outcomes[0]
totalWins = outcomes[1]
totalLosses = outcomes[2]
disProbWin = totalWins/totalGames
disProbLoss = 1-disProbWin
print (f'The discrete probability of winning is: {disProbWin}. The discrete probability of losing is {disProbLoss}')
disAmount = (100*disProbWin)-(100*disProbLoss)
print (f'The discrete expected value is {disAmount}')

```
The discrete probability of winning is: 0.4902574. The discrete probability of losing is 0.5097426
The discrete expected value is -1.948520000000002
```

# 1. import random and set seed

# 2. Input target sales and number of sales persons for upcoming year; low and high
# percentages of sales for generating random numbers

# 3. Generate a random sales amount for each rep and check that it is in the correct range
# Use a for loop; round answer to nearest cent

# 4. Add to your loop in # 3 to determine the commission for each rep
# (you need an if-elif-else construct to determine rate); keep a running tab of
# the sum of all commissions
# round all dollar amounts to nearest cent
#

# 5. Add a loop around your code in # 4 to do 10,000 simulations
# Only print out the average commission for all 10,000 simulations
# Don't print out all the information from Step # 4 - it will be way too much so remove
# or comment out those print statements
#