# import random library and set seed
import random
random.seed(12345)
n=random.randint(1,100)
print(n)

```
54
```

# 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.
import random
random.seed(123456)
def draw_ran_ball():
n=random.randint(1,100)
if (n>=52):
return True
else:
return False
draw_ran_ball()

# Step 2.
# Create a function which simulates playing the game n_plays times; keep track of number of wins and losses
def draw_mult_ball(n_times,money,bet):
wins=0
losses=0
for i in range(0,n_times):
if (draw_ran_ball()==True):
money=money+bet
wins=wins+1
else:
money=money-bet
losses=losses+1
return[wins,losses]
print(draw_mult_ball(5,10000,100))

```
[1, 4]
```

def draw_mult_ball(n_times,money,bet):
wins=0
losses=0
for i in range(0,n_times):
if (draw_ran_ball()==True):
money=money+bet
wins=wins+1
else:
money=money-bet
losses=losses+1
return[money,wins,losses]
print(draw_mult_ball(5,10000,100))

```
[9900, 2, 3]
```

num_wins=0
num_losses=0
totalmoney=0
outcomes=[0,0,0]
for i in range(100):
outcomes=draw_mult_ball(5,10000,100)
totalmoney=totalmoney+outcomes[0]
num_wins=num_wins+outcomes[1]
num_losses=num_losses+outcomes[2]
avg_money=totalmoney/100
print("The average amount of funds remaining when tou play 5 games is",avg_money)
disprob_win=num_wins/500
disprob_lose=1-disprob_win
print("The discrete probability of winning is",disprob_win,"and the discrete probability of losing is",disprob_lose)
ex_value=(100*disprob_win)-(100*disprob_lose)
print("The expected value is",ex_value)

```
The average amount of funds remaining when tou play 5 games is 10002.0
The discrete probability of winning is 0.502 and the discrete probability of losing is 0.498
The expected value is 0.4000000000000057
```

games = 5
rounds = 1000000
num_games = games*rounds
outcomes = draw_mult_ball(num_games,10000,100)
total_money= outcomes[0]
num_wins = outcomes[1]
num_losses = outcomes[2]
disprobwin = num_wins/num_games
disprobloss = 1-disprobwin
print("The discrete probability of winning is now",disprobwin,"and the discrete probability of losing is",disprobloss)
ex_value = (100*disprobwin)-(100*disprobloss)
print("The expected value is",ex_value)

```
The discrete probability of winning is now 0.4897312 and the discrete probability of losing is 0.5102688
The expected value is -2.053760000000004
```

#More total games are needed to be played to get a better approximation.

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

# 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
#