Score: I got a 1/1

Hack #1 - Class Notes

Write any extra notes you have here

  • Simulations are abstractions that mimic more complex objects or phenomena from the real world
  • Simulations use varying sets of values to reflect the changing state of a real phenomenon
  • Simulations allow the formulation of hypotheses under consideration
  • Variability and randomness of the world is considered using random number generators

Hack #2 - Functions Classwork

In this hack, I allowed the user to choose if they wanted to add or remove a clothing item from the closet. I printed their closet inventory afterwards.

import random
x = random.randint(1, 100)
print("The random number between 1 through 100 is: " + str(x))

user = int(input("Enter a positive integer: "))
y = random.randint(1, user)
print("The random number between 1 and " + str(user) + " is: " + str(y))

def mycloset():
    myclothes = ["red shoes", "green pants", "tie", "belt"]
    choice = str(input("Do you want to add an item or remove an item from your closet? Please enter 'add' or 'remove': "))
    if (choice == "add"):
        add = str(input("Clothing item to add to your closet: "))
        myclothes.append(add)
    else:
        throw = str(input("Clothing item to throw out: "))
        myclothes.remove(throw)
    return(myclothes)

mycloset()
The random number between 1 through 100 is: 26
The random number between 1 and 10 is: 3
['red shoes', 'green pants', 'tie', 'belt', 'pj pants']

Unfair Coin

This is an unfair coin with 2/3 chance heads and 1/3 chance tails :)

import random

def coinflip():         #def function 
    randomflip = random.randint(0, 2) #picks either 0 or 1 randomly (50/50 chance of either) 
    if randomflip == 0: #assigning 0 to be heads--> if 0 is chosen then it will print, "Heads"
        print("Tails")
    else:
        print("Heads")

#Tossing the coin 5 times:
t1 = coinflip()
t2 = coinflip()
t3 = coinflip()
t4 = coinflip()
t5 = coinflip()
Tails
Heads
Heads
Heads
Heads

Hack #3 - Binary Simulation Problem

Here, I used binary to determine if everyone on the list survived or got taken by the zombies... scary...

import random

def randomnum(): # function for generating random int
    return(random.randint(0, 255))
    

def converttobin(n): # function for converting decimal to binary
    return(format(n,'08b'))
    

def survivors(binary): # function to assign position
    survivorstatus = ["Jiya", "Shruthi", "Noor", "Ananya" , "Sophia", "Taylor Swift", "Ariana Grande", "Mariah Carey"]
    for i in range (0, 8):
        zombie = int(binary[i])
        if (zombie == 1):
            print(survivorstatus[i] + " survived!!")
        else:
            print(survivorstatus[i] + " GOT TAKEN BY THE ZOMBIES...")
    # replace the names above with your choice of people in the house

x = randomnum()
y = converttobin(x)
survivors(y)
Jiya GOT TAKEN BY THE ZOMBIES...
Shruthi GOT TAKEN BY THE ZOMBIES...
Noor survived!!
Ananya survived!!
Sophia GOT TAKEN BY THE ZOMBIES...
Taylor Swift GOT TAKEN BY THE ZOMBIES...
Ariana Grande GOT TAKEN BY THE ZOMBIES...
Mariah Carey GOT TAKEN BY THE ZOMBIES...

Hack #4 - Thinking through a problem

  • create your own simulation involving a dice roll
  • should include randomization and a function for rolling + multiple trials

In this hack, I decided to simulate if it was a weekend or weekday, telling the user if they had homework or if they could rest and sleep

def dayOfWeek():
    num = random.randint(1, 7)
    if (num == 6 or num == 7):
        return("it's a weekend!! have fun and rest and sleep :)")
    else:
        return("it's a weekday unfortunately, you have homework from school... good luck...")

print(dayOfWeek())
print(dayOfWeek())
print(dayOfWeek())
print(dayOfWeek())
it's a weekday unfortunately, you have homework from school... good luck...
it's a weekend!! have fun and rest and sleep :)
it's a weekday unfortunately, you have homework from school... good luck...
it's a weekday unfortunately, you have homework from school... good luck...

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

In this hack, I used a loop and dictionary, I also calculated score at the end and displayed if the user passed or not.

import random

print("Welcome to the quiz! For your answers, please enter in 'A', 'B', 'C', or 'D'! Thanks!")

def question(prompt, answer):
    msg = input("Question: " + prompt)
    if msg == answer:
        print(msg + " is correct!")
        return(1)
    else:
        print(msg + " is incorrect!")
        return(0)

# Append to List a Dictionary of key/values related to a person and cars
quiz = {
    "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. (A) The simulation is an abstraction and therefore cannot contain any bias (B) The simulation may accidentally contain bias due to the exclusion of details (C) If the simulation is found to contain bias, then it is not possible to remove the bias from the simulation (D) The only way for the simulation to be biased is if the researcher intentionally used data that favored their desired output": "B",
    "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? (A) No, it's not a simulation because it does not include a visualization of the results. (B) No, it's not a simulation because it does not include all the details of his life history and the future financial environment (C) Yes, it's a simulation because it runs on a computer and includes both user input and computed output. (D) Yes, it's a simulation because it is an abstraction of a real world scenario that enables the drawing of inferences.": "C",
    "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? (A) Realistic sound effects based on the material of the baseball bat and the velocity of the hit (B) A depiction of an audience in the stands with lifelike behavior in response to hit accuracy (C) Accurate accounting for the effects of wind conditions on the movement of the ball (D) A baseball field that is textured to differentiate between the grass and the dirt": "C",
    "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? (A) The simulation will not contain any bias that favors one body type over another, while an experiment will be biased (B) The simulation can be run more safely than an actual experiment (C) The simulation will accurately predict the parachute's safety level, while an experiment may be inaccurate due to faulty experimental design (D) The simulation can't test the parachute design in a wide range of environmental conditions that may be difficult to reliably reproduce in an experiment": "B",
    "True or False: Simulations are abstractions that mimic more complex objects or phenomena from the real world, (A) True (B) False": "A",
    "What do random number generators account for? (A) varaibility real world (B) make something not random (C) how ordered things are in the real world (D) doesn't affect result": "A"
}

numqs = 6
correct = 0

for item in quiz:
    num = question(item, quiz[item])
    correct = correct + num

print("You scored" + str(correct) +"/" + str(numqs))
print("Your percentage is " + str(correct/numqs*100) + "%! Good work!")
if (correct >= 5):
    print("You passed!")
else:
    print("You failed!")
Welcome to the quiz! For your answers, please enter in 'A', 'B', 'C', or 'D'! Thanks!
B is correct!
C is correct!
C is correct!
B is correct!
A is correct!
A is correct!
You scored6/6
Your percentage is 100.0%! Good work!
You passed!

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

For this hack, I made a random meal planne

def mealplanner():
    appetizers = ["pita chips and hummus", "tortilla chips and salsa", "guacamole", "spring rolls"]
    x = random.randint(0,3)

    mains = ["spaghetti", "mac and cheese", "pizza", "lasagna", "cheeseburgers", "dumplings"]
    y = random.randint(0, 5)

    dessert = ["tiramisu", "ice cream", "apple pie"]
    z = random.randint(0, 2)

    return("The meal is... " + appetizers[x] + ", " + mains[y] + ", and " + dessert[z])

mealplanner()
'The meal is... spring rolls, spaghetti, and apple pie'