"""
石头 剪刀 布
"""
import easygui # gui 界面
import random
# 出拳
win = 0
lose = 0
draw = 0punches = ['石头', '剪刀', '布']
computer = random.choice(punches)
user = box("大佬请出拳,请出剪刀石头布")
# message 信息
if user in punches:if (user == "石头" and computer == "剪刀") or (user == "布" and computer == "石头") or (user == "剪刀" and computer == "布"):win = win +1easygui.msgbox("大佬你赢了,电脑出了%s,赢了%s,输了%s,平局%s"%(computer,win,lose,draw))elif user == computer:draw = draw + 1easygui.msgbox("大佬我居然和你打平了,电脑出了%s,赢了%s,输了%s,平局%s"%(computer,win,lose,draw))else:lose = lose + 1easygui.msgbox("大佬你个菜鸡,电脑出了%s,赢了%s,输了%s,平局%s"%(computer,win,lose,draw))
else:easygui.msgbox("你个菜鸡,猜拳都不会")computer = random.choice(punches)
user = box("大佬请出拳,请出剪刀石头布")
# message 信息
if user in punches:if (user == "石头" and computer == "剪刀") or (user == "布" and computer == "石头") or (user == "剪刀" and computer == "布"):win = win +1easygui.msgbox("大佬你赢了,电脑出了%s,赢了%s,输了%s,平局%s"%(computer,win,lose,draw))elif user == computer:draw = draw + 1easygui.msgbox("大佬我居然和你打平了,电脑出了%s,赢了%s,输了%s,平局%s"%(computer,win,lose,draw))else:lose = lose + 1easygui.msgbox("大佬你个菜鸡,电脑出了%s,赢了%s,输了%s,平局%s"%(computer,win,lose,draw))
else:easygui.msgbox("你个菜鸡,猜拳都不会")computer = random.choice(punches)
user = box("大佬请出拳,请出剪刀石头布")
# message 信息
if user in punches:if (user == "石头" and computer == "剪刀") or (user == "布" and computer == "石头") or (user == "剪刀" and computer == "布"):win = win + 1easygui.msgbox("大佬你赢了,电脑出了%s,赢了%s,输了%s,平局%s" % (computer, win, lose, draw))elif user == computer:draw = draw + 1easygui.msgbox("大佬我居然和你打平了,电脑出了%s,赢了%s,输了%s,平局%s" % (computer, win, lose, draw))else:lose = lose + 1easygui.msgbox("大佬你个菜鸡,电脑出了%s,赢了%s,输了%s,平局%s" % (computer, win, lose, draw))
else:easygui.msgbox("你个菜鸡,猜拳都不会")
·```# 2.0
```python
"""
石头 1 剪刀2 布3
WIN
computer person RESULT
1 3 -2
2 1 1
3 2 1LOSE
computer person RESULT
1 2 -1
2 3 -1
3 1 2DRAW
computer person RESULT
1 1 0
2 2 0
3 3 0"""
import easygui # gui 界面
import random
# 出拳
win = 0
lose = 0
draw = 0punches = [1, 2, 3]
for i in range(5):computer = random.choice(punches)user = box("大佬请出拳,请出剪刀2石头1布3"))# message 信息result = computer - userif user in punches:if result == -2 or result == 1 :win = win +1easygui.msgbox("大佬你赢了,电脑出了%s,赢了%s,输了%s,平局%s"%(computer,win,lose,draw))elif user == computer:draw = draw + 1easygui.msgbox("大佬我居然和你打平了,电脑出了%s,赢了%s,输了%s,平局%s"%(computer,win,lose,draw))else:lose = lose + 1easygui.msgbox("大佬你个菜鸡,电脑出了%s,赢了%s,输了%s,平局%s"%(computer,win,lose,draw))else:easygui.msgbox("你个菜鸡,猜拳都不会")
本文发布于:2024-01-29 01:14:00,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170646204511656.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |