'''
小遊戲:剪刀,石頭,布
規則:剪刀可以剪布,石頭可以磕碰剪刀,而布可以抱住石頭
程式輸入:剪刀,石頭,布 與電腦隨機產生的剪刀,石頭,布做對比
choice()從序列中隨機生產乙個元素
'''from random import *
li = ['剪刀','石頭','布']
while true:
n = str(input("請輸入剪刀,石頭,布:"))
n_c = choice(li)
if (n == '剪刀' and n_c == '布') or (n == '布' and n_c =='石頭') or (n == '石頭' and n_c == '剪刀'):
print('玩家出,電腦出,玩家獲勝'.format(n,n_c))
elif n == n_c:
print('玩家出,電腦出,平局'.format(n, n_c))
elif n == 'q':
break
else:
print('玩家出,電腦出,電腦獲勝'.format(n, n_c))
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小遊戲 石頭剪刀布
import random pc random.randint 1,3 a none if pc 1 a 石頭 elif pc 2 a 剪刀 else a 布 player input 請輸入剪刀石頭布 if a 石頭 and player 剪刀 or a 剪刀 and player 布 or a ...
石頭 剪刀 布小遊戲
先建立建立乙個遊戲規則 石頭 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 ...