Question: Keep the same exact topics such as ( individual , couple, group ) , ( outdoors , indoors, river ) , and the same activities,

Keep the same exact topics such as (individual, couple, group),(outdoors, indoors, river), and the same activities, but make sure the output is changed so that it is a different code for the same topic with the same variables.
def display_welcome_message():
#Display the welcome message.
print("Welcome! Let's find an activity based on your preferences.")
def get_who_choice():
#Prompt the user to enter 'couple', 'group', or 'individual'.
while True:
who = input("Please enter who will be participating (individual, couple, group) or 'none' to exit: ").lower()
if who in ['individual', 'couple', 'group']:
return who
elif who == 'none':
return None
else:
print("Invalid input. Please enter 'individual', 'couple', 'group', or 'none' to exit.")
def get_where_choice():
#Prompt the user to enter 'indoors', 'outdoors', or 'river'.
while True:
where = input("Where will the activity take place? (indoors, outdoors, river): ").lower()
if where in ['indoors', 'outdoors', 'river']:
return where
else:
print("Invalid input. Please enter 'indoors', 'outdoors', or 'river'.")
def select_activity(who, where):
#Return the activity based on who and where.
activities ={
('individual', 'indoors'): 'Crafts',
('individual', 'outdoors'): 'Biking',
('individual', 'river'): 'Fishing',
('couple', 'outdoors'): 'Hiking',
('group', 'indoors'): 'Scavenger hunt',
('group', 'outdoors'): 'Rock climbing',
('group', 'river'): 'Tubing'
}
return activities.get((who, where),"No activity found for the given choices.")
def main():
#Main function to run the activity selection process.
display_welcome_message()
while True:
who = get_who_choice()
if who is None:
print("Exiting the program.")
break
where = get_where_choice()
activity = select_activity(who, where)
print(f"The selected activity for a {who} in the {where} is: {activity}")
#Run the program
if __name__=="__main__":
main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!