**Programming: Instantiation and While Loops**

I’ve actually used instantiations in Unity a couple of times now: once during the Asteroid game we made in class and at the Game Jam for our Sonar Slalom game. In terms of code, instantiation is a running process where it creates an object within the program based on a parent object (identifier). An example of this would be the generation of the asteroids, where they would show up in intervals of every few seconds at various spots along the playable screen. In the bat game, the obstacles were instantiated off screen and used a script to move them across screen until they could be destroyed once off screen again.

While loops are both useful and dangerous if not used correctly, because they can be a huge memory hog or crash the entire system if they get caught in an infinite loop. I’ve come across them in SQL before, which is a language primarily used in database management, and we were always warned to double-check our while loops in case they cause an infinite loop.

In our context, it’s called a “control flow statement” that runs a piece of code over and over again until the given condition is no longer met. This is usually based on a Boolean, so it will be asking if the condition is true or false, and a while loop is often just called a repeating if statement. The syntax is the same as an if statement, it just is a better way to handle certain programming situations.

**Maths: Probability and Averages**

The essence of probability is in the name: told in numbers, it’s the chance/likelihood of something happening. Finding probabilities can be done by taking the number of ways the outcome could happen and divide it by the total number of possible outcomes. There are a couple example of this:

- Rolling a die, what’s the likelihood of getting an even number? 3/6 = 1/2 = 50%
- Tossing a coin, what’s the likelihood of getting heads? 1/2 = 50%
- Choosing a candy from a bag that contains 4 different colours, what’s the likelihood of getting green? 1/4 = 25%
- Looking at the days of the week, what’s the likelihood of choosing Sunday at random? 1/7 = 14.3%

Meanwhile, measuring averages is about finding the number that’s typical in a set of numbers. There are a few types: mean, median, and mode. We’re meant to be covering those in class, but I’ll look at them briefly here to just expand on measures of averages.

Mean: this is the most common measure of averages. It’s achieved by taking the sum of the numbers and dividing by the amount of number. Ex) 1 + 2 + 3 + 4 = 10 / 4 = average of 2.5.

Median: You place your set of numbers in order and the median is equal to the one that falls in the middle. If you have two middle numbers (so an even amount of numbers in your set), then it’s the mean of those two numbers that’s the median. Ex) 1, 1, 2, 3, 3, 4 = 2 and 3 = average of 2.5

Mode: This one is quite simple in that it’s the number that appears most often in the set. It’s also the only type of average that can have more than one value. Ex) 1, 2, 2, 2, 3, 4, 4 = average of 2