Skip to content

Instantly share code, notes, and snippets.

@falconser
Last active March 31, 2023 17:48
Show Gist options
  • Save falconser/66ec3f118daa4bda4e92702453152c3c to your computer and use it in GitHub Desktop.
Save falconser/66ec3f118daa4bda4e92702453152c3c to your computer and use it in GitHub Desktop.
def weekend_trip_quiz():
# Quiz questions and corresponding options
questions = [
"Which do you prefer: Spending time on the beach or exploring historical sites?",
"How important is it for you to see famous landmarks?",
"What type of food do you prefer?",
"Do you enjoy hiking or walking in nature?",
"What kind of activities do you enjoy in the evening?",
"How important is it for you to be close to the city?",
"Do you enjoy water sports such as surfing or windsurfing?",
"What type of accommodations do you prefer?",
"What type of weather do you prefer?",
"How important is it for you to escape the crowds and enjoy peace and quiet?"
]
options = [
["Beach (Guincho Praia)", "Historical sites (City of Cintra)"],
["Very important (City of Cintra)", "Not important (Guincho Praia)"],
["Seafood (Guincho Praia)", "Traditional Portuguese cuisine (City of Cintra)"],
["Yes (City of Cintra)", "No (Guincho Praia)"],
["Live music and dancing (Guincho Praia)", "Relaxing with a glass of wine (City of Cintra)"],
["Very important (City of Cintra)", "Not important (Guincho Praia)"],
["Yes (Guincho Praia)", "No (City of Cintra)"],
["Beachfront hotel (Guincho Praia)", "Historic hotel or guesthouse (City of Cintra)"],
["Sunny and warm (Guincho Praia)", "Mild and comfortable (City of Cintra)"],
["Very important (City of Cintra)", "Not important (Guincho Praia)"]
]
# Quiz options and their corresponding trip destinations
results = {
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9): "City of Cintra",
(1, 0, 2, 0, 1, 1, 1, 1, 1, 1): "City of Cintra",
(0, 1, 0, 1, 0, 0, 0, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 1, 1, 1, 1, 1, 1): "City of Cintra",
(0, 1, 0, 1, 0, 0, 0, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 1, 1, 1, 1, 1, 1): "City of Cintra",
(0, 1, 0, 1, 1, 0, 1, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 0, 1, 0, 1, 1, 1): "City of Cintra",
(0, 1, 0, 1, 0, 0, 0, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 1, 1, 1, 1): "City of Cintra",
(0, 1, 0, 1, 1, 0, 0, 0, 1, 0): "Guincho Praia",
(1, 0, 1, 0, 0, 1, 1, 1, 0, 1): "City of Cintra",
(0, 1, 0, 1, 1, 0, 0, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 0, 1, 1, 1, 0, 1): "City of Cintra",
(0, 1, 0, 1, 1, 0, 0, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 1, 1, 1, 1, 0, 1): "City of Cintra",
(0, 1, 0, 1, 0, 0, 0, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 1, 1, 1, 1, 1, 1): "City of Cintra",
(0, 1, 0, 1, 1, 0, 1, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 0, 1, 0, 1, 0, 1): "City of Cintra",
(0, 1, 0, 1, 0, 0, 0, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 1, 1, 1, 1, 1, 1): "City of Cintra",
(0, 1, 0, 1, 1, 0, 0, 0, 1, 0): "Guincho Praia",
(1, 0, 1, 0, 0, 1, 1, 1, 0, 1): "City of Cintra",
(0, 1, 0, 1, 0, 0, 0, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 1, 1, 1, 1, 1, 1): "City of Cintra",
(0, 1, 0, 1, 1, 0, 1, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 0, 1, 0, 1, 1, 1): "City of Cintra",
(0, 1, 0, 1, 0, 0, 0, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 1, 1, 1, 1, 1, 1): "City of Cintra",
(0, 1, 0, 1, 0, 0, 0, 0, 0, 0): "Guincho Praia"
def get_user_choice(answers):
"""
Given a tuple of 10 answers, determine the user's preferred option.
"""
if answers in QUIZ_RESULTS:
return QUIZ_RESULTS[answers]
else:
return "Invalid answers"
QUIZ_RESULTS = {
(1, 1, 0, 0, 1, 1, 0, 0, 0, 0): "City of Cintra",
(0, 1, 0, 1, 1, 0, 0, 0, 1, 0): "Guincho Praia",
(1, 0, 1, 0, 0, 1, 1, 1, 0, 1): "City of Cintra",
(0, 1, 0, 1, 1, 0, 0, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 0, 1, 1, 1, 0, 1): "City of Cintra",
(0, 1, 0, 1, 1, 0, 0, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 1, 1, 1, 1, 0, 1): "City of Cintra",
(0, 1, 0, 1, 0, 0, 0, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 1, 1, 1, 1, 1, 1): "City of Cintra",
(0, 1, 0, 1, 1, 0, 1, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 0, 1, 0, 1, 0, 1): "City of Cintra",
(0, 1, 0, 1, 0, 0, 0, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 1, 1, 1, 1, 1, 1): "City of Cintra",
(0, 1, 0, 1, 1, 0, 1, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 0, 1, 1, 1, 0, 1): "City of Cintra",
(0, 1, 0, 1, 0, 0, 0, 0, 0, 0): "Guincho Praia",
(1, 0, 1, 0, 1, 1, 1, 1, 1, 1): "City of Cintra",
(0, 1, 0, 1, 1, 0, 1, 0 def run_quiz():
"""
Runs the quiz and returns the user's preferred option.
"""
print("Welcome to the weekend trip quiz!")
print("Please answer the following questions to determine your preferred option: ")
answers = []
for i in range(10):
answer = input(f"Question {i+1}: {QUIZ_QUESTIONS[i]} (Enter 1 for Yes, 0 for No): ")
while answer not in ["0", "1"]:
answer = input("Invalid response. Please enter 1 for Yes or 0 for No: ")
answers.append(int(answer))
return get_user_choice(tuple(answers))
if __name__ == "__main__":
print(run_quiz())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment