用户:
12345lcy查看:0 回复:0 评论:0 创建时间:2021-02-18T18:52:50
【作品展示】

【作品介绍】
希望给赞不能说我了
【作品源代码】
import turtle
import random
__Pen = turtle.Pen()
print('我无语了你们据然说我。我希望有点赞')
myscreen = turtle.Screen()
t = turtle.Pen()
t.hideturtle()
count = 0
p_win = 0
c_win = 0
flag = False
while (count < 10):
player = int(turtle.textinput('攻1—2防—3破', ' 攻克破 防克攻 破克防 请输入对应的数字 只能填1~3'))
computer = random.randint(1, 3)
count = (count + 1)
if (player == 1):
print('玩家出了:攻')
elif (player == 2):
print('玩家出了:防')
elif (player == 3):
print('玩家出了:破')
else:
print('玩家输入数字超出范围')
if (computer == 1):
print('计算机出了:攻')
elif (computer == 2):
print('计算机出了:防')
else:
print('计算机出了:布')
# 判断胜负
if (player == computer or flag):
print('此局是平局')
t.pencolor('gray')
t.dot(20)
flag = False
elif (player == 1 and computer == 3 or player == 2 and computer == 1 or player == 3 and computer == 2):
print('此局玩家赢')
p_win = (p_win + 1)
t.pencolor('darkgreen')
t.dot(20)
elif (player == 3 and computer == 1 or player == 1 and computer == 2 or player == 2 and computer == 3):
print('此局电脑赢')
c_win = (c_win + 1)
t.pencolor('red3')
t.dot(20)
else:
pass
t.penup()
t.forward(25)
t.pendown()
conut = (count + 1)
print('-------------')
print('玩家的胜局数为', p_win)
print('计算机的胜局数为', c_win)
turtle.done()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn