Unit 3.16 Hacks
Hack #1
- An idea for a simulation is a coin flipping simulation to get data of how it lands. This is a simulation because the coin is not flipped in real life. The advantage is that more data can be found more efficiently. The disadvantage is that it might not have the the small change of landing on its side or different power in the coin flip and air resistance.
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
- What makes it a simulation?: This is a simulation because the program generates a random number from 1 to 6. It is also a simulation because the dice is not being rolled in real life but it is rolled in a program.
- What are it’s advantages and disadvantages?: The advantages of simulation are that it allows a lot of data of the dice results to be found in almost an instant. The disadvantage is that the dice would not experience the real life factors like air resistance, the power put into the roll, and friction.
- In your opinion, would an experiment be better in this situation?: I think in this situation, a simulation is better because an experiment would take really long to get enough data.
import random
rolls = int(input("How many rolls do you want?"))
while rolls > 0:
diceResult = random.randint(1, 14)
print("The 14-sided die landed on", diceResult)
rolls -= 1
import random
days = int(input("How many days?"))
sunny = 0
rainy = 0
cloudy = 0
windy = 0
stormy = 0
while days > 0:
weather = random.randint(1, 5)
if weather == 1:
print("The weather is sunny")
sunny += 1
elif weather == 2:
print("The weather is rainy")
rainy += 1
elif weather == 3:
print("The weather is cloudy")
cloudy += 1
elif weather == 4:
print("The weather is windy")
windy += 1
elif weather == 5:
print("The weather is stormy")
stormy += 1
days -= 1
print("Sunny:", sunny)
print("Rainy:", rainy)
print("Rainy:", rainy)
print("Cloudy:", cloudy)
print("Stormy:", stormy)
This is a simulation because it simulate the weather with a 20 percent chance of each one over a certain desired amount of days. This is done on a computer not in real life. The advantages of the simulation is that it is easier to and quicker to get data. The disadvantage is that the weather is not always the same probability to get each one. An experiment is better in this situation because the data would be more accurate than a simulation.