Question Answer
Name (First+Last) Ishi Singh
1 --
2 --
3 C
4 B
5 C
6 A
7 A
8 --
9 B

Extra

Show your understanding. You could make a simple simulation, define vocab, etc.

WHAT QUESTIONS

3: What is not a reason to use a pseudo-random number generator when making a simulation?


A: To mock imperfections from the real world
B: To save resources
C: To make the simulation more accurate

4: Which of the following is the least likely factor to be removed from a flight(air traffic) simulation for functionality?
A: Weather
B: Other aircraft
C: Imperfections on aircraft

Experiment/Calculation or Simulation

5: What is not (usually) a difference between a experiment and a simulation?
A: Resources and time needed
B: Factors considered
C: Situation considered

For each situation answer: Would it make more sense to use a simulation or a experiment/calculation?

6: A car company needs to know how safe it's customers will be if it's new car crashes
A: Simulation
B: Experiment/calculation

7: A environmental group wants an accurate guess on the impact the greenhouse effect will have on the environment
A: Simulation
B: Experiment/calculation

9: A teacher want's to find the average score from a final
A: Simulation
B: Experiment/calculation

Lesson Takeaway

Simulations are useful for a variety of purposes in coding. Some of the benefits of using simulations include:

  1. Testing and debugging: Simulations can be used to test and debug code by allowing developers to see how their code behaves in different scenarios. This can be especially useful when working with complex systems or when trying to identify and fix issues that might not be immediately apparent.
  2. Modeling and prediction: Simulations can be used to model and predict the behavior of real-world systems, allowing developers to better understand and predict how a system will behave under different conditions.
  3. Expense: Simulations can also help reduce the cost for testing since less equipment is required to test code.

Overall, simulations are an important tool that can help developers to design, test, and optimize their code, and to better understand and predict the behavior of complex systems.

Making a Simulation

The simulation below give the time, position, and velocity values of an object which is in free fall. It starts with an inital position of 50m and an inital velocity of 0m/s. And it changes these values based on the time value 10 times.

g = 9.8 ## Gravity in m/s^2
dt = 0.25 ## This is the step value for time in s
x = 50 ## Inital position in m
v = 0 ## Inital velocity in m/s

for t in range(10): ## For the first 10 values
    x = x + v * dt ## This calculates the position and velocity  ## xf = xi + vt
    v = v - g * dt  ## vf = vi + at

    x = round(x, 3)  ## Rounds to 3 decimal places
    v = round(v, 3)
    
    print("Time:", t+dt,"       ", "Position:", x,"        ", "Velocity:", v)
Time: 0.25         Position: 50.0          Velocity: -2.45
Time: 1.25         Position: 49.388          Velocity: -4.9
Time: 2.25         Position: 48.163          Velocity: -7.35
Time: 3.25         Position: 46.325          Velocity: -9.8
Time: 4.25         Position: 43.875          Velocity: -12.25
Time: 5.25         Position: 40.812          Velocity: -14.7
Time: 6.25         Position: 37.137          Velocity: -17.15
Time: 7.25         Position: 32.849          Velocity: -19.6
Time: 8.25         Position: 27.949          Velocity: -22.05
Time: 9.25         Position: 22.437          Velocity: -24.5