Hack #1 - Class Notes

  • simulations are abstractions that mimic more complex objects/phenomena from the real world in order to draw inferences without the constraints of the real world
  • use varying sets of values to reflect changing state of a real phenomena
  • it is often necessary to remove specific details or simplify aspects, which can cause bias
  • allow the formulation of hypotheses under consideration randomness/variability of the world is considered using random number generators

air traffic simulator- you can use a simulation to explore the optimal number of aircrafts that can be in the air in one time without real world constraints of money, time, safety may have bias, may not always have same result

Hack #2 - Functions Classwork

import random 
x = random.randint(0,100)
print(x)
36
import random
def mycloset():
    myclothes = ["jeans", "hoodie", "socks", "hat"]
    for clothes in myclothes:
        x = random.choice(myclothes) 
        myclothes.remove(x)
        m = myclothes 
    print(m)
    print(x + " was removed")

mycloset()


        
['socks', 'hat']
hoodie was removed
import random

def coinflip():         
    coins = random.randint(0, 2) 
    if coins == 0 or coins == 1: 
        print("Heads")
    else:
            print("Tails")


t1 = coinflip()
t2 = coinflip()
t3 = coinflip()
t4 = coinflip()
t5 = coinflip()
Heads
Heads
Tails
Tails
Heads

Hack #3 - Binary Simulation Problem

import random

def randomnum(): 
    return random.randint(0,255)

def converttobin(n): 
    return (format(n, "08b"))

def survivors(bin): 
    status = ['sabine', 'alyssa', 'taylor swift', 'nathan', 'haseeb', 'wednesday addams', 'trisha paytas', 'monaleo']
    for i in range(0,7):
        zombified = int(bin[i])
        if zombified == 1:
            print(status[i] + " is a loser and got zombified")
        else:
            print(status[i] + " DIDN'T DIE! hallelujah")

a = randomnum()
b = converttobin(a)
survivors(b)


        
sabine DIDN'T DIE! hallelujah
alyssa is a loser and got zombified
taylor swift DIDN'T DIE! hallelujah
nathan DIDN'T DIE! hallelujah
haseeb is a loser and got zombified
wednesday addams DIDN'T DIE! hallelujah
trisha paytas is a loser and got zombified

Hack #4 - Thinking through a problem

  • create your own simulation involving a dice roll
  • should include randomization and a function for rolling + multiple trials
import random
def diceroll():
    return random.randint(1,6)
for i in range(5):
    x = diceroll()
    print("you rolled {}".format(x))
you rolled 1
you rolled 1
you rolled 6
you rolled 1
you rolled 1

Hack 5 - Applying your knowledge to situation based problems

Using the questions bank below, create a quiz that presents the user a random question and calculates the user's score. You can use the template below or make your own. Making your own using a loop can give you extra points.

  1. 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:
      1. The simulation is an abstraction and therefore cannot contain any bias
      2. The simulation may accidentally contain bias due to the exclusion of details.
      3. If the simulation is found to contain bias, then it is not possible to remove the bias from the simulation.
      4. The only way for the simulation to be biased is if the researcher intentionally used data that favored their desired output.
  2. 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
      1. No, it's not a simulation because it does not include a visualization of the results.
      2. No, it's not a simulation because it does not include all the details of his life history and the future financial environment.
      3. Yes, it's a simulation because it runs on a computer and includes both user input and computed output.
      4. Yes, it's a simulation because it is an abstraction of a real world scenario that enables the drawing of inferences.
  3. 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
      1. Realistic sound effects based on the material of the baseball bat and the velocity of the hit
      2. A depiction of an audience in the stands with lifelike behavior in response to hit accuracy
      3. Accurate accounting for the effects of wind conditions on the movement of the ball
      4. A baseball field that is textured to differentiate between the grass and the dirt
  4. 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
      1. The simulation will not contain any bias that favors one body type over another, while an experiment will be biased.
      2. The simulation can be run more safely than an actual experiment
      3. The simulation will accurately predict the parachute's safety level, while an experiment may be inaccurate due to faulty experimental design.
      4. 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
  5. YOUR OWN QUESTION; can be situational, pseudo code based, or vocab/concept based
  6. YOUR OWN QUESTION; can be situational, pseudo code based, or vocab/concept based
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.",
    "1) The simulation is an abstraction and therefore cannot contain any bias.", 
    "2) The simulation may accidentally contain bias due to the exclusion of details.", 
    "3) If the simulation is found to contain bias, then it is not possible to remove the bias from the simulation.", 
    "4) The only way for the simulation to be biased is if the researcher intentionally used data that favored their desired output.",
    ["2"]),
    ("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?",
    "1) No, it's not a simulation because it does not include a visualization of the results.", 
    "2) No, it's not a simulation because it does not include all the details of his life history and the future financial environment.", 
    "3) Yes, it's a simulation because it runs on a computer and includes both user input and computed output.", 
    "4) Yes, it's a simulation because it is an abstraction of a real world scenario that enables the drawing of inferences.",
    ["3"]),
    ("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?",
    "1) Realistic sound effects based on the material of the baseball bat and the velocity of the hit.", 
    "2) A depiction of an audience in the stands with lifelike behavior in response to hit accuracy.", 
    "3) Accurate accounting for the effects of wind conditions on the movement of the ball.",
    "4) A baseball field that is textured to differentiate between the grass and the dirt.",
    ["3"]),
    ("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?",
    "1) The simulation will not contain any bias that favors one body type over another, while an experiment will be biased.", 
    "2) The simulation can be run more safely than an actual experiment.", 
    "3) The simulation will accurately predict the parachute's safety level, while an experiment may be inaccurate due to faulty experimental design.", 
    "4) The simulation can test the parachute design in a wide range of environmental conditions that may be difficult to reliably reproduce in an experiment.",
    ["2"]),
    ("simulations are",
    "1) dumb and stupid", 
    "2) abstractions that mimic more complex objects/phenomena from the real world in order to draw inferences without the constraints of the real world", 
    "3) abstractions that are always wrong", 
    "4) absolutely unexplainable",
    ["2"]),
    ("simulations are often not accurate to real life because",
    "1) theyre awful", 
    "2) stupid people made them", 
    "3) certain details may need to be removed or simplified for the sake of the simulation", 
    "4) im failing this class",
    ["3"])
]

correct = 0
total = 6
def PQ(tup):
    print(tup[0])
    print(tup[1])
    print(tup[2])
    print(tup[3])
    print(tup[4])


def questionloop():
    correct = 0
    quest = 6
    for i in range(len(questions)):
        PQ(questions[i])
        answer = input("choose an answer")
        if answer in questions[i][5]:
            print("ok youre not dumb")
            correct+=1
        else:
            print("youre dumb")
    return correct

correct = questionloop()
print("you got {0} questions right. there were {1}. what does this say about you?".format(correct, total))
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.
1) The simulation is an abstraction and therefore cannot contain any bias.
2) The simulation may accidentally contain bias due to the exclusion of details.
3) If the simulation is found to contain bias, then it is not possible to remove the bias from the simulation.
4) The only way for the simulation to be biased is if the researcher intentionally used data that favored their desired output.
ok youre not dumb
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?
1) No, it's not a simulation because it does not include a visualization of the results.
2) No, it's not a simulation because it does not include all the details of his life history and the future financial environment.
3) Yes, it's a simulation because it runs on a computer and includes both user input and computed output.
4) Yes, it's a simulation because it is an abstraction of a real world scenario that enables the drawing of inferences.
ok youre not dumb
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?
1) Realistic sound effects based on the material of the baseball bat and the velocity of the hit.
2) A depiction of an audience in the stands with lifelike behavior in response to hit accuracy.
3) Accurate accounting for the effects of wind conditions on the movement of the ball.
4) A baseball field that is textured to differentiate between the grass and the dirt.
ok youre not dumb
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?
1) The simulation will not contain any bias that favors one body type over another, while an experiment will be biased.
2) The simulation can be run more safely than an actual experiment.
3) The simulation will accurately predict the parachute's safety level, while an experiment may be inaccurate due to faulty experimental design.
4) The simulation can test the parachute design in a wide range of environmental conditions that may be difficult to reliably reproduce in an experiment.
ok youre not dumb
simulations are
1) dumb and stupid
2) abstractions that mimic more complex objects/phenomena from the real world in order to draw inferences without the constraints of the real world
3) abstractions that are always wrong
4) absolutely unexplainable
youre dumb
simulations are often not accurate to real life because
1) theyre awful
2) stupid people made them
3) certain details may need to be removed or simplified for the sake of the simulation
4) im failing this class
youre dumb
you got 4 questions right. there were 6. what does this say about you?

Hack #6 / Challenge - Taking real life problems and implementing them into code

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...

import random


def DOTW():
    shows = ['wednesday', 'inside job', 'greys anatomy', 'big mouth', 'criminal minds', 'no show']
    foods = ['filet mignon', 'a dead rat', 'gordon ramsey', 'nothing', 'chips and salsa']
    x = random.choice(shows) 
    v = random.choice(foods)

    print("you'll be watching " + x + " while eating " + v + " sometime this week")

        

    


        
DOTW()
        
        
      
    
you'll be watching greys anatomy while eating filet mignon sometime this week