Hack 1: Create Your Own Algorithm

Activity chosen: Making a pizza from scratch

Algorithm:

  1. Gather ingredients: flour, yeast, water, salt, olive oil, tomato sauce, cheese, and toppings.
  2. Mix flour, yeast, water, salt, and olive oil in a bowl to form dough.
  3. Knead the dough for about 10 minutes until smooth and elastic.
  4. Cover the dough with a cloth and let it rise for 1–2 hours.
  5. Preheat the oven to 475°F (245°C).
  6. Roll out the dough into a circular shape on a floured surface.
  7. Spread tomato sauce evenly on the rolled-out dough.
  8. Add shredded cheese on top of the sauce.
  9. Place chosen toppings (pepperoni, veggies, etc.) on top of the cheese.
  10. Put the pizza in the oven and bake for 12–15 minutes.
  11. Remove pizza from oven, let it cool slightly, then slice and serve.

Hack 2: Identify the Bug

Algorithm (Corrected): 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”

Hack 3: Code the Algorithm


def calculate_grade(score1, score2, score3):
    """
    Calculate letter grade from three test scores
    
    Args:
        score1, score2, score3: Test scores (integers)
    
    Returns:
        grade: Letter grade (string)
    """
    # 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 using if-elif-else
    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

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