Recap - Vacation Filter
Part of the Logic & Flow section of Coddy's Python journey — lesson 28 of 78.
Challenge
EasyWrite a program that checks if a vacation package meets a customer's requirements.
Your program should:
- 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)
- 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
Trueor both areFalse, as long as they are equal
- 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 = TrueExample Output:
Package is suitableAnother Example (both prefer non-family-friendly — still a match):
destination = "Hawaii"
price = 1999
nights = 4
family_preference = False
package_family_friendly = FalsePackage is suitableTry 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
1Variables Exploration
ConstantsMultiple Variable AssignmentsSwapping VariablesPlaceholder VariablesRound NumbersList Casting4Contact Book Application
Display MenuAdd Contact7Sets Part 2
Mathematical Operations Part 1Mathematical Operations Part 2Recap - Treasure HuntSubsets and SupersetsIterating Over SetsRecap - Tournament Tracker2Dictionaries Part 1
What is a Dictionary?Creating a DictionaryAccessing ValuesModifying DictionariesRecap - Recipe Manager5Advanced Decision Making
Ternary OperatorMembership ChecksIdentity ChecksIndentation ErrorsRecap - Vacation Filter8Student Records Manager
Project OverviewAdd Student11Advanced Functions
Returning Multiple ValuesLambda Functions Part 1Lambda Functions Part 2Recap Challenge - Lambda SortRecursive Functions Part 1Recursive Functions Part 2Recap - Sum Nested List14Higher-Order Functions
The Map FunctionThe Filter FunctionRecap - Email ValidatorRecap - Number Processor3Dictionaries Part 2
Dictionary MethodsNested DictionariesChecking for KeysLooping Through DictionariesRecap - Frequency Counter9Advanced Data Aggregation
Using SumFinding Minimum and MaximumSorting Data EfficientlyRecap - Dictionary Sorter