Unit 3 Lesson 16, Student Copy
- Hack #1 - Class Notes
- Hack #2 - Functions Classwork
- Hack #3 - Binary Simulation Problem
- Hack #4 - Thinking through a problem
- Hack 5 - Applying your knowledge to situation based problems
- Hack #6 / Challenge - Taking real life problems and implementing them into code
import random
myclothes = ['Black Shoes','Jeans','Grey Shorts','Tan Shorts','Black T-Shirt']
def throwout():
y = len(myclothes)-1
x = random.randint(0,y)
myclothes.remove(myclothes[x])
print(myclothes)
throwout()
print(myclothes)
import random
survivorstatus = ["William Hartnell", "Partic Troughton", "John Pertwee", "Tom Baker" , "Peter Davison", "Colin Baker", "Sylvester McCoy", "Paul McGann"]
def randomnum(): # function for generating random int
x = random.randint(0,255)
return x
def converttobin(n): # function for converting decimal to binary
thelist = []
while n > 0:
if n % 2 == 0:
thelist.append(0)
n = n / 2
else:
thelist.append(1)
n = n / 2
n = n - 0.5
while len(thelist) < 8:
thelist.append(0)
return thelist
def survivors(binary,survivors): # function to assign position
survivorlist = []
for i in range(len(binary)):
if binary[i] == 0:
survivorlist.append(survivors[i])
else:
print('dead')
return survivorlist
assignments = converttobin(randomnum())
remaining = survivors(assignments,survivorstatus)
print('Remaining Survivors:',remaining)
# replace the names above with your choice of people in the house
from random import randint
def rolldice():
sides = int(input('dice side count:'))
rolls = int(input('number of rolls:'))
out = []
for i in range(rolls):
x = randint(0,sides)
out.append(x)
return(out)
print(rolldice())
- A researcher gathers data about the effect of Advanced Placement®︎ classes on students' success in college and career, and develops a simulation to show how a sequence of AP classes affect a hypothetical student's pathway.Several school administrators are concerned that the simulation contains bias favoring high-income students, however.
- answer options:
- The simulation is an abstraction and therefore cannot contain any bias
- The simulation may accidentally contain bias due to the exclusion of details.
- If the simulation is found to contain bias, then it is not possible to remove the bias from the simulation.
- The only way for the simulation to be biased is if the researcher intentionally used data that favored their desired output.
- answer options:
- Jack is trying to plan his financial future using an online tool. The tool starts off by asking him to input details about his current finances and career. It then lets him choose different future scenarios, such as having children. For each scenario chosen, the tool does some calculations and outputs his projected savings at the ages of 35, 45, and 55.Would that be considered a simulation and why?
- answer options
- No, it's not a simulation because it does not include a visualization of the results.
- No, it's not a simulation because it does not include all the details of his life history and the future financial environment.
- Yes, it's a simulation because it runs on a computer and includes both user input and computed output.
- Yes, it's a simulation because it is an abstraction of a real world scenario that enables the drawing of inferences.
- answer options
- Sylvia is an industrial engineer working for a sporting goods company. She is developing a baseball bat that can hit balls with higher accuracy and asks their software engineering team to develop a simulation to verify the design.Which of the following details is most important to include in this simulation?
- answer options
- Realistic sound effects based on the material of the baseball bat and the velocity of the hit
- A depiction of an audience in the stands with lifelike behavior in response to hit accuracy
- Accurate accounting for the effects of wind conditions on the movement of the ball
- A baseball field that is textured to differentiate between the grass and the dirt
- answer options
- Ashlynn is an industrial engineer who is trying to design a safer parachute. She creates a computer simulation of the parachute opening at different heights and in different environmental conditions.What are advantages of running the simulation versus an actual experiment?
- answer options
- The simulation will not contain any bias that favors one body type over another, while an experiment will be biased.
- The simulation can be run more safely than an actual experiment
- The simulation will accurately predict the parachute's safety level, while an experiment may be inaccurate due to faulty experimental design.
- The simulation can test the parachute design in a wide range of environmental conditions that may be difficult to reliably reproduce in an experiment.
- this question has 2 correct answers
- answer options
correct = 0
questions = {
"A researcher gathers data about the effect of Advanced Placement classes on students' success in college and career, and develops a simulation to show how a sequence of AP classes affect a hypothetical student's pathway.Several school administrators are concerned that the simulation contains bias favoring high-income students, however.":["The simulation is an abstraction and therefore cannot contain any bias","The simulation may accidentally contain bias due to the exclusion of details.","If the simulation is found to contain bias, then it is not possible to remove the bias from the simulation.","The only way for the simulation to be biased is if the researcher intentionally used data that favored their desired output."],
"Jack is trying to plan his financial future using an online tool. The tool starts off by asking him to input details about his current finances and career. It then lets him choose different future scenarios, such as having children. For each scenario chosen, the tool does some calculations and outputs his projected savings at the ages of 35, 45, and 55.Would that be considered a simulation and why?":["No, it's not a simulation because it does not include a visualization of the results.","No, it's not a simulation because it does not include all the details of his life history and the future financial environment.","Yes, it's a simulation because it runs on a computer and includes both user input and computed output.","Yes, it's a simulation because it is an abstraction of a real world scenario that enables the drawing of inferences."],
"Sylvia is an industrial engineer working for a sporting goods company. She is developing a baseball bat that can hit balls with higher accuracy and asks their software engineering team to develop a simulation to verify the design.Which of the following details is most important to include in this simulation?":["Realistic sound effects based on the material of the baseball bat and the velocity of the hit","A depiction of an audience in the stands with lifelike behavior in response to hit accuracy","Accurate accounting for the effects of wind conditions on the movement of the ball","A baseball field that is textured to differentiate between the grass and the dirt"],
"Ashlynn is an industrial engineer who is trying to design a safer parachute. She creates a computer simulation of the parachute opening at different heights and in different environmental conditions.What are advantages of running the simulation versus an actual experiment?":["The simulation will not contain any bias that favors one body type over another, while an experiment will be biased.","The simulation can be run more safely than an actual experiment","The simulation will accurately predict the parachute's safety level, while an experiment may be inaccurate due to faulty experimental design.","The simulation can test the parachute design in a wide range of environmental conditions that may be difficult to reliably reproduce in an experiment."]
}
def answers(question):
used = []
for i in range(len(questions[question])):
option = random.randint(0,3)
while option in used == True:
option = random.randint(0,3)
used.append(option)
print(questions[question][option])
#Q1
Q1 = "A researcher gathers data about the effect of Advanced Placement classes on students' success in college and career, and develops a simulation to show how a sequence of AP classes affect a hypothetical student's pathway.Several school administrators are concerned that the simulation contains bias favoring high-income students, however."
print(Q1)
answers(Q1)
solution = input('Please type the answer here, keep in mind the exact capitalization and punctuation as shown.')
if solution == "If the simulation is found to contain bias, then it is not possible to remove the bias from the simulation.":
correct = correct + 1
Q2 = "Jack is trying to plan his financial future using an online tool. The tool starts off by asking him to input details about his current finances and career. It then lets him choose different future scenarios, such as having children. For each scenario chosen, the tool does some calculations and outputs his projected savings at the ages of 35, 45, and 55.Would that be considered a simulation and why?"
print(Q2)
answers(Q2)
solution = input('Please type the answer here, keep in mind the exact capitalization and punctuation as shown.')
if solution == "Yes, it's a simulation because it runs on a computer and includes both user input and computed output.":
correct = correct + 1
Q3 = "Sylvia is an industrial engineer working for a sporting goods company. She is developing a baseball bat that can hit balls with higher accuracy and asks their software engineering team to develop a simulation to verify the design.Which of the following details is most important to include in this simulation?"
print(Q3)
answers(Q3)
solution = input('Please type the answer here, keep in mind the exact capitalization and punctuation as shown.')
if solution == "Accurate accounting for the effects of wind conditions on the movement of the ball":
correct = correct + 1
Q4 = "Ashlynn is an industrial engineer who is trying to design a safer parachute. She creates a computer simulation of the parachute opening at different heights and in different environmental conditions.What are advantages of running the simulation versus an actual experiment?"
print(Q4)
answers(Q4)
solution = input('Please type the answer here, keep in mind the exact capitalization and punctuation as shown.')
if solution == "The simulation can be run more safely than an actual experiment":
correct = correct + 1
elif solution == "The simulation can test the parachute design in a wide range of environmental conditions that may be difficult to reliably reproduce in an experiment.":
correct = correct + 1
print( " you scored " + str(correct) +"/" + str(len(questions)))
Create your own simulation based on your experiences/knowledge! Be creative! Think about instances in your own life, science, puzzles that can be made into simulations
Some ideas to get your brain running: A simulation that breeds two plants and tells you phenotypes of offspring, an adventure simulation...