##Student Teaching, Algorithms

###Find the median test grade of a class

testscores = [85, 92, 78, 90, 88, 76, 95, 89, 83, 91]

testscores.sort()

num_scores = len(testscores)

if num_scores % 2 == 1: median = testscores[num_scores // 2] else: middle1 = testscores[num_scores // 2 - 1] middle2 = testscores[num_scores // 2] median = (middle1 + middle2) / 2

print(f”The median test score is: {median}”)

Create a simple game with numbers import random

secret_number = random.randint(1, 100)

attempts = 0

while True: try: guess = int(input(“Guess the secret number (between 1 and 100): “)) attempts += 1

if guess == secret_number:
    print(f"Congratulations! You guessed the secret number {secret_number} in {attempts} attempts.")
    break
elif guess < secret_number:
    print("Try a higher number.")
else:
    print("Try a lower number")

except ValueError: print(“Enter a valid number.”)