Re: [問題] 卡關了...

看板Python作者 (殺.人.鬼)時間17年前 (2006/10/28 03:10), 編輯推噓5(502)
留言7則, 4人參與, 最新討論串4/5 (看更多)
More pythontic way: import random times = 100 history = [random.choice(('head', 'tail')) for i in range(times)] for i in history: print i print 'head:', history.count('head') print 'tail:', history.count('tail') -- ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ - ██◤ ◥█◤ ██◣ ██◣ ██◤ ◢██ -▅▃ █ █ █ █▄▄ █ █ █ ◣ ◢ / - █ ██◢█ ▄▄▌ █ █ ◤ ◥ ◢█◣ █ ◣ ██◤ █ ██◤ ▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃▃ Mozilla Firefox -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.123.224.181

10/28 11:04, , 1F
金害...有越來越看不懂的趨勢...
10/28 11:04, 1F

10/29 09:57, , 2F
這樣寫漂亮很多 酷
10/29 09:57, 2F

10/29 09:58, , 3F
我是寫c轉寫python的 xD
10/29 09:58, 3F

10/29 14:15, , 4F
大推 :)
10/29 14:15, 4F

11/01 06:10, , 5F
但是這樣寫吃 linear space 喔. XD
11/01 06:10, 5F

11/01 16:05, , 6F
times 不大的前提下,我覺得程式看起來清楚比較重要耶!?
11/01 16:05, 6F

11/01 16:06, , 7F
不然這樣寫不僅記憶體吃得多,就連執行速度也比較慢啊 @@?
11/01 16:06, 7F
文章代碼(AID): #15GbcsP0 (Python)
討論串 (同標題文章)
文章代碼(AID): #15GbcsP0 (Python)