Homework Hack

Directions:

Task List:

  1. Get Age: Prompt the user to enter their age.
  2. Check Ball Ownership: Ask if they have a ball (yes/no).
  3. Check Eligibility: Verify if they are at least 5 years old and have a ball.
  4. Determine Group: Assign a play group based on age (under 8 or 8 and older).
  5. Display Result: Print whether they can join the game and their group.

Solution:

# Input age and whether the child has a ball
age = int(input("Enter your age: "))
has_ball = input("Do you have a ball? (yes/no): ").lower()

# Check if the child can join the game
can_join_game = age >= 5 and has_ball == "yes"

if can_join_game:
    if age < 8:
        message = "You can play with the younger kids."
    else:
        message = "You can play with the older kids."

    print(f"Great! {message}")
else:
    print("Sorry, you can't join the game yet.")
Sorry, you can't join the game yet.