python石头剪刀布代码(if,elif,else练习)
作者:互联网
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("请输入规定的数字哦")
标签:elif,平局,python,石头,print,else,剪刀 来源: https://blog.csdn.net/qq_46241284/article/details/121577869