{}

Build your resume with HTML & CSS and win $100

Get featured on Programiz PRO and the Wall of Inspiration.

Build your resume with HTML & CSS and win $100

Join Challenge →
Join Challenge →

Build your resume with HTML & CSS and win $100

Get featured on Programiz PRO and the Wall of Inspiration.

Build your resume with HTML & CSS and win $100

Join Challenge →
Join Challenge →
run-icon
main.py
import random # A list of names for males and females male_names = ["John", "Mike", "James", "David", "Chris", "Alex", "Matthew", "Daniel", "Mark", "Ryan"] female_names = ["Emily", "Sarah", "Jessica", "Anna", "Sophia", "Olivia", "Isabella", "Mia", "Ava", "Charlotte"] # The hobbies and interests available in the app available_hobbies = ["Reading", "Cooking", "Gaming", "Hiking", "Music", "Swimming", "Painting", "Photography", "Cycling", "Dancing"] available_interests = ["Art", "Technology", "Sports", "Science", "Travel", "Movies", "History", "Music", "Books", "Fashion"] # Function to ask the user for their profile information def get_user_input(): # Ask for the basic profile details username = input("Enter your username: ") age = int(input("Enter your age: ")) # Check if the user is 18 or older if age < 18: print("Sorry, this is an 18+ site. You must be 18 or older to continue.") return None # Stop the program if the user is not 18+ # Ask for gender and validate the input gender = input("Enter your gender (Male/Female): ").capitalize() while gender not in ["Male", "Female"]: print("Invalid input. Please enter 'Male' or 'Female'.") gender = input("Enter your gender (Male/Female): ").capitalize() # Ask for gender preference and validate it gender_preference = input("Enter your gender preference (Male/Female): ").capitalize() while gender_preference not in ["Male", "Female"]: print("Invalid input. Please enter 'Male' or 'Female'.") gender_preference = input("Enter your gender preference (Male/Female): ").capitalize() # Ask for the location and validate the input location = input("Enter your location (Guadalajara, London, Paris, Tokyo, Sydney): ").capitalize() while location not in ["Guadalajara", "London", "Paris", "Tokyo", "Sydney"]: print("Invalid location. Please choose from these locations.") location = input("Enter your location (Guadalajara, London, Paris, Tokyo, Sydney): ").capitalize() # Ask for hobbies and validate the input print("Available hobbies: ", available_hobbies) hobbies = input("Enter at least two hobbies from the list, separated by commas: ").split(", ") while len(hobbies) < 2 or not all(hobby in available_hobbies for hobby in hobbies): print("You must choose at least two hobbies from the list.") hobbies = input("Enter at least two hobbies from the list, separated by commas: ").split(", ") # Ask for interests and validate the input print("Available interests: ", available_interests) interests = input("Enter at least two interests from the list, separated by commas: ").split(", ") while len(interests) < 2 or not all(interest in available_interests for interest in interests): print("You must choose at least two interests from the list.") interests = input("Enter at least two interests from the list, separated by commas: ").split(", ") return username, age, gender, gender_preference, location, hobbies, interests # Function to create a random profile for matching def generate_random_profile(user_gender_preference): # Generate a random gender for the profile based on user's preference if user_gender_preference == "Male": random_gender = "Male" name = random.choice(male_names) # Random male name elif user_gender_preference == "Female": random_gender = "Female" name = random.choice(female_names) # Random female name # Random age between 18 and 70 random_age = random.randint(18, 70) # Random location from available options random_location = random.choice(["Guadalajara", "London", "Paris", "Tokyo", "Sydney"]) # Randomly pick two hobbies random_hobbies = random.sample(available_hobbies, 2) # Randomly pick two interests random_interests = random.sample(available_interests, 2) return name, random_age, random_gender, random_location, random_hobbies, random_interests # Function to calculate how much the user's profile matches the random profile def calculate_match(user_hobbies, user_interests, random_hobbies, random_interests, user_location, random_location): match_score = 0 # Compare hobbies if any(hobby in random_hobbies for hobby in user_hobbies): match_score += 30 # 30% for matching hobbies # Compare interests if any(interest in random_interests for interest in user_interests): match_score += 30 # 30% for matching interests # Compare location if user_location == random_location: match_score += 10 # 10% for matching location return match_score # Main function to find a match def find_match(): user_input = get_user_input() if user_input is None: return # Stop the program if the user is under 18 username, age, gender, gender_preference, location, hobbies, interests = user_input match_found = False # Keep generating random profiles until a match is found while not match_found: random_profile = generate_random_profile(gender_preference) # Calculate how much the profiles match match_score = calculate_match(hobbies, interests, random_profile[4], random_profile[5], location, random_profile[3]) print(f"Checking profile: {random_profile[0]} (Age: {random_profile[1]}, Gender: {random_profile[2]}, Location: {random_profile[3]})") # If the match score is 70% or higher, it's a match! if match_score >= 70: print(f"Match found with {random_profile[0]}! Match score: {match_score}%") match_found = True else: print(f"No match with {random_profile[0]}. Trying again...") print("End of program.") # Start the matching process find_match()
Output