Skip to the content.

Algorithms

Student Teaching Lesson

Popcorn Hack/interctive portion

PopcornHack


Homework Hack 1

Algorithm: Getting Ready for a Basketball Game

  1. Put on your uniform.

  2. Pack your bag with water, towel, and gear.

  3. Eat a light meal for energy.

  4. Fill your water bottle.

  5. Sretch to warm up.

  6. Change into clean game clothes.

  7. Go to the gym early.

  8. Tie your shoes and get ready to play.

Homework Hack 2

Corrected Algorithm: Send an Email

  1. Open email application

  2. Log into your account

  3. Enter recipient’s email address

  4. Write subject line

  5. Type the message

  6. Click “Send”

Homework Hack 3

def calculate_grade(score1, score2, score3):
    """
    Calculate letter grade from three test scores.
    """
    # Step 1: Add the three scores together
    total = score1 + score2 + score3

    # Step 2: Calculate the average
    average = total / 3

    # Step 3: Determine the letter grade
    if average >= 90:
        grade = 'A'
    elif average >= 80:
        grade = 'B'
    elif average >= 70:
        grade = 'C'
    elif average >= 60:
        grade = 'D'
    else:
        grade = 'F'

    # Step 4: Return the grade
    return grade

# Test the function
print("Test 1:", calculate_grade(95, 92, 88))  # A
print("Test 2:", calculate_grade(85, 80, 82))  # B
print("Test 3:", calculate_grade(75, 70, 72))  # C
print("Test 4:", calculate_grade(65, 60, 62))  # D
print("Test 5:", calculate_grade(55, 50, 52))  # F

Test 1: A
Test 2: B
Test 3: C
Test 4: D
Test 5: F