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

# Step 1.
# Define a function which randomly draws a ball with an integer between 1 and 100 on it;
x = random.randint (1, 100)
# then returns True if Player
if x > 51:
print ('True, The player wins')
else:
print ('False, The house wins')
print(f'The number drawn is {x}')
# 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
#

```
False, The house wins
The number drawn is 23
```

# Step 2.
# Create a function which simulates playing the game n_plays times; keep track of number of wins and losses
def game(n_plays):
Player_win_count = 0
House_win_count = 0
for i in range (0, n_plays):
x = random.randint (1, 100)
if x > 51:
Player_win_count +=1
print (x, 'Win')
else:
House_win_count +=1
print (x, 'Loss' )
print ('Won', Player_win_count)
print ('Lost', House_win_count)
game (5)

```
1 Loss
85 Win
10 Loss
7 Loss
35 Loss
Won 1
Lost 4
```

def game (n_plays):
Player_win_count = 0
House_win_count = 0
Money_total = 10000
for i in range (n_plays):
x = random.randint (1, 100)
Money_total -=100
if x >51:
Player_win_count += 1
Money_total +=200
print (x, 'Win')
else:
House_win_count += 1
print (x, 'Loss')
print ('Won', Player_win_count)
print ('Lost', House_win_count)
game (5)

```
83 Win
48 Loss
6 Loss
24 Loss
99 Win
Won 2
Lost 3
```

Player_win_count = 0
House_win_count = 0
Money_total = 0
for i in range (100):
Money_total += 0
Player_win_count += 0
House_win_count += 0
Money_total = totalfunds/100
print (f'The average amount of funds left after 5 games: {avgfunds}')

NameError: name 'results' is not defined

def game (n_plays):
Player_win_count = 0
House_win_count = 0
Money_total = 10000
for i in range (n_plays):
x = random.randint (1, 100)
Money_total -=100
if x >51:
Player_win_count += 1
Money_total +=200
print (x, 'Win')
else:
House_win_count += 1
print (x, 'Loss')
print ('Won', Player_win_count)
print ('Lost', House_win_count)
print (f' i dont understand the second half')

```
i dont understand the second half
```

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