# import random library and set seed
import numpy as np
# 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 lotto():
ball = np.random.randint(1, 100)
print(f"Drew: {ball}")
if (ball < 50):
return 0
else:
return 1
result = lotto()
if (result == 0):
print(f"Player wins.")
else:
print(f"House wins.")
# Step 2.
# Create a function which simulates playing the game n_plays times; keep track of number of wins and losses
#
def game_cycle(n_plays):
count = 0
for i in range (0, n_plays):
x = lotto()
if (x == 0):
count += 1
return count
wins = game_cycle(10)
print(f"Wins: {wins}")
funds = 10000
wins = 0
for i in range (0, 5):
state = game_cycle(1)
if (state > 0):
wins += 1
funds += 200
else:
funds -= 100
print(f"${funds} remaining, {wins} wins.")
total = 0
for j in range (0, 100):
funds = 10000
for i in range (0, 5):
state = game_cycle(1)
if (state > 0):
funds += 200
else:
funds -= 100
total += funds
print(f"\n")
average = total/100
print(f"Average funds after 100 5 game sets: ${average}")
# 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
#