看板 AllTogether 關於我們 聯絡資訊
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") -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 58.114.212.150 ※ 文章網址: https://www.ptt.cc/bbs/AllTogether/M.1559132667.A.188.html ※ 編輯: as30385438 (58.114.212.150), 05/29/2019 20:26:58
joaya: 有特色 223.136.34.197 05/29 20:27
a3236852: 哈哈哈哈有點幽默欸114.137.220.117 05/29 20:27
pannacotta23: 徵男? 49.219.162.231 05/29 20:27
Tenno081: 你是不是標錯了?應該標徵女吧? 114.136.246.45 05/29 20:28
CGHS: 徵男? 祝福了! 雖然我不是SW但看得懂XD 27.52.62.157 05/29 20:28
max241: 這title 跟內容 直接critical error 123.193.6.110 05/29 20:28
BeautyIsDie: but you want a man in the title? 123.192.223.72 05/29 20:29
VivianChen01: 徵男 ? 0.0 140.114.225.18 05/29 20:29
sam0991: 祝福 110.26.235.105 05/29 20:30
※ 編輯: as30385438 (58.114.212.150), 05/29/2019 20:31:20 感謝大家,寫code寫到腦殘XD ※ 編輯: as30385438 (58.114.212.150), 05/29/2019 20:32:04
iLeyaSin365: 你是不是徵求性別弄錯了 42.70.177.6 05/29 20:31
c5i3n1g: 看程式碼之前比較喜歡先看註解 42.75.163.197 05/29 20:58
chenycal: 以前人家都說mis都怪怪的,我原本不相信 115.82.16.112 05/29 21:17
chenycal: 直到........ 115.82.16.112 05/29 21:17
banana800908: 不會寫Python,但是看得懂XD 111.71.102.68 05/29 21:22
JJHu: 其實感覺只要看得懂英文即可 114.39.193.163 05/29 21:33
andyher: 無聊 150.117.2.57 05/29 21:36
rtyleo: 徵男無誤...... 223.137.64.188 05/29 21:43
glender: 有創意 110.28.203.241 05/29 21:57
hakosaki: 加油好嗎......換做我是女生也直接pass 1.200.218.252 05/29 21:57
hakosaki: 感覺你的生活只有程式碼 1.200.218.252 05/29 21:57
pureguy: 我女生,我看完了,幽默給推XD 111.71.70.133 05/29 22:04
bmw606042001: 好宅 36.229.254.163 05/29 22:15
我不是MIS哦,SW跟MIS還差滿多的 然後會走這行當然就是熱愛coding啦,宅也是我的一部分 能接受的女生再寄信給我吧 ※ 編輯: as30385438 (58.114.212.150), 05/29/2019 22:25:55
jingpikapika: 太有梗了推~ 114.136.84.131 05/29 22:29
dreamed: ...114.137.179.173 05/29 22:39
Tenno081: 有信了,恭喜阿 114.136.246.45 05/29 22:47
doublelove82: 也覺得會英文就看得懂了 39.12.133.5 05/29 23:21
Rokopeko: python還真直覺,物件就這樣寫啊 39.9.137.242 05/29 23:23
Giuliani: XDDDDDD180.217.148.188 05/29 23:34
BJoker8672: Line51 AttributeError: 'NoneType' o 166.216.158.95 05/29 23:44
BJoker8672: bject has no attribute 'height' 166.216.158.95 05/29 23:44
parisdog: 好想學 42.77.208.70 05/30 02:04
ABC610478: 自以為 118.232.12.92 05/30 03:23
Hirajima: 會英文就看得懂了啦www 114.45.207.42 05/30 03:43
dream1103: Python本是最好上手的程式語言,語法也 220.132.72.92 05/30 06:11
dream1103: 是最簡略的 220.132.72.92 05/30 06:11
harry7319: 推 101.13.146.238 05/30 07:53
okita3088: 如果是我連看都不想看 117.19.212.115 05/30 08:08
walhalla: 沒作過SA膩,最重要的車房存款年薪都沒有 211.21.123.187 05/30 12:45
costello: 哈哈 好宅 114.35.206.216 05/30 16:48
cwinny: 雖然不會寫但看得懂,沒想到這個這麼直觀223.137.161.146 05/30 19:24
cwinny: 喔長知識223.137.161.146 05/30 19:24
hhc16: 覺得超棒的 49.216.16.136 05/31 08:44