#!/root/kl/bin/python3
# 小遊戲 石頭剪刀布
#author:kl
import random
all_choices =
['石頭'
,'剪刀'
,'布'
]computer = random.choice(all_choices)
w_list =[[
'石頭'
,'剪刀'],
['剪刀'
,'布'],
['布'
,'石頭']]
shuoming =
'''(0) 石頭
(1) 剪刀
(2) 布
請選擇(0/1/2)'''
num =
int(
input
(shuoming)
)#將說明轉為數字
player = all_choices[num]
#說明的數字為all_choices的下標
print
("your choice: %s, computer's choice: %s"
%(player,computer)
)if player == computer:
print
('勢均力敵'
)elif
['player'
,'computer'
]in w_list:
print
('you win!!!'
)else
:print
('you lose!!!'
)
石頭 剪刀 布小遊戲
先建立建立乙個遊戲規則 石頭 0 剪刀 1 布 2.贏的情況有三種,分別是 情況匹配 前減後贏差值 前減後輸差值 0贏1,1 1 1贏2,1 1 2贏0.2 2 hand input 石頭 剪刀 布,你要出哪乙個呢 if hand in 石頭 剪刀 布 if hand 石頭 hand 0 elif ...
python 石頭剪刀布小遊戲
import random import time print 石頭剪刀布小遊戲!time.sleep 3 for i in range 6 for k in range 5 i print end for j in range 2 i 1 print end print for i in rang...
python小遊戲 剪刀,石頭,布
小遊戲 剪刀,石頭,布 規則 剪刀可以剪布,石頭可以磕碰剪刀,而布可以抱住石頭 程式輸入 剪刀,石頭,布 與電腦隨機產生的剪刀,石頭,布做對比 choice 從序列中隨機生產乙個元素 from random import li 剪刀 石頭 布 while true n str input 請輸入剪刀...