class PttUser:
def __init__(self, height, weight, city, gender, age, job, verbose):
self.height = height
self.weight = weight
self.city = city
self.gender = gender
self.age = age
self.job = job
self.verbose = verbose
self.bmi = weight / (self.height ** 2 / 10000)
self.hobbies = {"ptt"}
my_data = {
"height": 176,
"weight": 74,
"city": "Taipei",
"gender": "male",
"age": 27,
"job": "software engineer"
}
my_data["verbose"] = "no smoking, no drinking, outgoing, hen好相處"
my_hobbies = {"dancing", "marvel", "weight training", "games", "TV series (EA
or KOREAN)"}
me = PttUser(**my_data)
me.hobbies.update(my_hobbies)
def calc_my_score(me, you):
score = 0
if 155 < you.height <= 160:
score += 20
elif you.height <= 155:
score += 30
if you.bmi < 22:
score += 20
if 22 <= you.age <= 30:
score += 20
score += len(me.hobbies.intersection(you.hobbies)) * 20
return score
user2calc = {
me: calc_my_score,
# and all others including you
}
for you,calc_your_score in user2calc.items():
my_score = calc_my_score(me, you)
your_score = calc_your_score(you,me)
if my_score + your_score > 140:
if you.gender == "female":
print("please send me a letter, we can exchange our photos if you
want")
if you.gender == "male":
print("thanks but I like girls")