python石头剪刀布代码(if elif else练习)
import random
a = int (input("请输入:剪刀(0),石头(1),布(2):"))
x = random.randint(0,2)
if a ==0:
if x==0:
print("平局哦,我是剪刀")
elif x==1:
print("你输了哦,我是石头")
else:
print("你赢了哦,我是布")
elif a==1:
if x==0:
print("你赢了哦,我是剪刀")
elif x==1:
print("平局哦,我是石头")
else:
print("你输了哦,我是布")
elif a==2 :
if x== 0:
print("你输了哦,我是剪刀")
elif x==1:
print("你赢了哦,我是石头")
else:
print("平局哦,我是布")
else:
print("请输入规定的数字哦")