- What makes it a simulation?
- A simulation is a automated process made to replicate a situation to get the output or practice.
- What are it’s advantages and disadvantages?
- Some advantages are that it is easier and it takes less resources to actually do vs an experiment where is can be costly and hard. A disadvantage is that it is not as accurate as it does not take into account the outside factors
- In your opinion, would an experiment be better in this situation?
- It depends on the situation
Hack #1 (0.3) Create an idea for a simulation and describe it (you don’t actually have to code it just think about/answer the guiding questions).
- You can simulate picking a random card from a deck of cards
- Since there are 52 cards you will need to have some type of random number generator and assign each number to a card so when it randomly picks a card it will match it to a number
- This is a simulation because it is not real and uses code to replicate
- Its easier than actually picking a card however it is not accurate
- I think an experiment would be better because sometimes when picking cards it is not alwas exactly random
Hack #2 (0.1) Simulations Quiz (either screenshot or paste quiz in your notebook)
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 (0.2) Describe the rolling dice simulation (answer guiding questions)
- This rolling dice simulation is a simulation because you are not actually rolling the dice instead you are creating code to replicate it.
- It is more efficient and you don't actually need the dice to replicate it. It is less accurate than having an experiment because depending on the way you roll the dice it is not always exactly random
- In my opinion I think that in order to have proper results, rolling the dice by hand would be better because there are definitely outside factors
Hack #4 (0.3) 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)
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)
Colors = []
# New Feature
for i in roll_results:
if i == 1:
Colors.append("red")
if i ==2:
Colors.append("blue")
if i==3:
Colors.append("black")
if i ==4:
Colors.append("green")
if i ==5:
Colors.append("grey")
if i ==6:
Colors.append("purple")
print("random colors:", Colors)
Extra Credit (0.1) For the extra 0.1: try coding a simple simulation and describe it (guiding question)
import random
num = random.randrange(0,5)
weather = ["rainy", 'thunder', 'snowy', 'windy', 'sunny']
print(weather[num])
In this simulation that I created, it uses the random library to get a random number in the range (0,5) Once this number is generated it goes through the weather list and goes in with the index of the random numer to generate a random weather This is a good simulation because it generates a random weather and this can show the weather of a day
- This is a simulation because it is just generating a random weather based off of code rather than real life factors
- Its good because it is easy to use and you do not need access to expensive weather measuring tools however it is definitely innaccurate
- I think it would be better to have a real experiment because this way in my simulation, it is innacurate