Lesson 3.16 Hack
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).
- My idea for a simulation is a car engine testing simulation. The simulation will run through different environment and each environment will have different chance to cause The engine to fail. The simulation will run until the engine fails and show how many test did engine lasted.
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")
import random
num_dice_input = input("How many times do you want to roll?")
def countInput(input_string):
if input_string.strip() in {"1", "2", "3","4", "5", "6"}:
return int(input_string)
num_dice = countInput(num_dice_input)
def rollDice(numDice):
result = []
for i in range(numDice):
roll = random.randint(1, 6)
result.append(roll)
return result
roll_results = rollDice(num_dice)
def total(list):
total = 0
for number in list:
number = int(number)
total += number
return total
sum = total(roll_results)
print("you rolled:", roll_results)
print("The sum is: ", sum)
import random
test = random.randint(1,3)
if test == 1:
print("The product is not capable")
if test == 2:
print("Ok, but still needs testing")
if test == 3:
print("It's all set")