function findMedian(data) {
    // Sort the data in ascending order
    data.sort((a, b) => a - b);

    const n = data.length;

    // If the number of data points is odd, return the middle value
    if (n % 2 !== 0) {
        return data[Math.floor(n / 2)];
    } else {
        // If the number of data points is even, return the average of the two middle values
        const mid1 = data[n / 2 - 1];
        const mid2 = data[n / 2];
        return (mid1 + mid2) / 2;
    }
}

// Example
const classData = [85, 92, 78, 95, 88];
const median = findMedian(classData);
console.log("Median:", median);
  Cell In[21], line 1
    function findMedian(data) {
             ^
SyntaxError: invalid syntax
import random

x = input("Do you want to flip a coin? (y/n)")
#x = str(x)

if x == "y":
    coin_flip = random.randint(0, 1)
    if coin_flip == 0:
        print("You landed tails!")
    else:
        print("You landed heads!")
        
# If they don't want to flip a coin
elif x == "n":
    print("Maybe next time!")
else:
    print("I\'m not sure what you mean")
    


1
You landed heads!