Menu
Coddy logo textTech

Recap - Vacation Filter

Part of the Logic & Flow section of Coddy's Python journey — lesson 28 of 78.

challenge icon

Challenge

Easy

Write a program that checks if a vacation package meets a customer's requirements.

Your program should:

  1. Take the following inputs:
    • destination: The vacation destination (a string)
    • price: The package price (a float)
    • nights: Number of nights included (an integer)
    • family_preference: Whether customer wants family-friendly (a boolean)
    • package_family_friendly: Whether package is family-friendly (a boolean)
  2. Evaluate if the package is suitable based on these conditions:
    • Destination must be "Hawaii" or "Bahamas"
    • Price must be less than $2000
    • Package must include at least 4 nights
    • Family-friendliness must match customer's preference — the package is suitable whether both are True or both are False, as long as they are equal
  3. Print the result:
    • "Package is suitable" if all conditions are met
    • "Package is not suitable" if any condition is not met

Note: For boolean inputs, enter 1 for True and 0 for False.

Important: The family-friendliness condition checks that family_preference == package_family_friendly. A customer who does not want a family-friendly package (0) is satisfied by a package that is also not family-friendly (0). Do not require both to be True — they simply need to match.

Example Input:

destination = "Hawaii"
price = 1800
nights = 5
family_preference = True
package_family_friendly = True

Example Output:

Package is suitable

Another Example (both prefer non-family-friendly — still a match):

destination = "Hawaii"
price = 1999
nights = 4
family_preference = False
package_family_friendly = False
Package is suitable

Try it yourself

# Get inputs from the user
destination = input()
price = float(input())
nights = int(input())
family_preference = bool(int(input()))     # 1 for True, 0 for False
package_family_friendly = bool(int(input()))  # 1 for True, 0 for False

# Check if the package is suitable
# Condition 1: Check destination
if ():
    # Condition 2: Check price and nights
    if ():
        # Condition 3: Check family-friendliness preference
        if ():
            print("Package is suitable")
        else:
            print("Package is not suitable")
    else:
        print("Package is not suitable")
else:
    print("Package is not suitable")

All lessons in Logic & Flow