3.16 Hacks
Hack #1
Create an idea for a simulation and describe it (you don’t actually have to code it just think about/answer the guiding questions).
- An idea for a simulation could be:
- A company wants to give their product and business more attraction, but they do not know how much money to spend on advertising (Where they will post their flyers in multiple locations and billboards) and do not want to spend too much money, so they are trying to find the optimal amount of flyers and money to spend. They create a simulation where in each location that their posters are placed, 1 in every 200 people will call the business/product and 1 in every 1300 people will buy the business/product. They have the populations for every location their advertisements are in and run it. This is a simulation because it is similar to real life, but is not as accurate as an actual experiment because there can't be a definite probability that a person will be interested in said product. However, the simulation will save a lot more time and money at the cost of its imminent inaccuracy.
questions_number = 6
answers_correct = 0
questions = [
"True or False: Simulations will always have the same result. \n A: True, \n B: False",
"True or False: A simulation has results that are more accurate than an experiment \n A: True, \n B: False",
"True or False: A simulation can model real world events that are not practical for experiments \n A: True, \n B: False",
"Which one of these is FALSE regarding simulations \n A: Reduces Costs, \n B: Is safer than real life experiments, \n C: More Efficient, \n D: More accurate than real life experiments",
"Which of the following scenarios would be the LEAST beneficial to have as a simulation \n A: A retail company wants to identify the item which sold the most on their website, \n B: A restaurant wants to determine if the use of robots will increase efficiency, \n C: An insurance company wants to study the impact of rain on car accidents, \n D: A sports car company wants to study design changes to their new bike design ",
"Which of the following is better to do as a simulation than as a calculation \n A: Keeping score at a basketball game, \n B: Keeping track of how many games a person has won, \n C: Determining the average grade for a group of tests, \n D: Studying the impact of carbon emissions on the environment"
]
question_answers = [
"B",
"B",
"A",
"D",
"A",
"D"
]
print("Welcome to the Simulations Quiz!")
def ask_question (question, answer):
print("\n", question)
user_answer = input(question)
print("You said: ", user_answer)
if user_answer == answer:
print("Correct!")
global answers_correct
answers_correct = answers_correct + 1
else:
print("You are incorrect")
for num in range(questions_number):
ask_question(questions[num], question_answers[num])
print("You scored: ", answers_correct, "/6")
Hack #3
Describe the rolling dice simulation (answer guiding questions)
- What makes it a simulation?
- The simulation is, well, a simulation is because the results that the dice outputs will not always be the same and therefore it emulates that of real life.
- What are it’s advantages and disadvantages?
- The advantage is that the results that the computer outputs can be more time efficient, and can save money (if someone is being payed and such to roll the dice at random). However, the dice game may not be as accurate as a real life demonstrate because of some variable or factor (like the face the dice is being rolled at, height above the surface, etc.)
- In your opinion, would an experiment be better in this situation? In my opinion, the dice as a simulation would be better because you can receive a large amount of data from the simulation that would otherwise be similar to an experiment -- random -- and in addition save some time.
Hack #4
Add a feature onto the rolling dice simulation above ex: a 14-sided dice or expand the purpose of the simulation (hint: use conditionals to make dice part of a game/real life situation) I added conditionals similar to something like a casino, the place where dice are used the most Below are the conditionals used in the simulation
for item in roll_results:
if item == 1 or item == 6:
print("Oh! Sorry! You lost all your earnings!")
elif item == 2 or item == 3:
print("Oh, sorry! You earned nothing! Want to play again?")
elif item == 4:
print("Woah! You're so lucky! You just earned yourself $100!")
elif item == 5:
print("Lucky lucky! You just earned $1000!")
elif item == 7:
print("You earned all of the casino's earnings! Get my joke?")
def parse_input(input_string):
if input_string.strip() in {"1", "2", "3","4", "5", "6"}:
return int(input_string)
else:
print("Please enter a number from 1 to 6.")
raise SystemExit(1)
import random
def roll_dice(num_dice):
roll_results = []
for _ in range(num_dice):
roll = random.randint(1, 6)
roll_results.append(roll)
return roll_results
num_dice_input = input("How many dice do you want to roll? [1-6] ")
num_dice = parse_input(num_dice_input)
roll_results = roll_dice(num_dice)
print("you rolled:", roll_results)
for item in roll_results:
if item == 1 or item == 6:
print("Oh! Sorry! You lost all your earnings!")
elif item == 2 or item == 3:
print("Oh, sorry! You earned nothing! Want to play again?")
elif item == 4:
print("Woah! You're so lucky! You just earned yourself $100!")
elif item == 5:
print("Lucky lucky! You just earned $1000!")
elif item == 7:
print("You earned all of the casino's earnings! Get my joke?")