用户:
我是锅铲"查看:0 回复:0 评论:0 创建时间:2022-05-01T22:20:22
【作品展示】

【作品介绍】
无
【作品源代码】
import turtle
import random
a = turtle.Pen()
length =200
a.pensize(40)
a.pencolor("lightsalmon")
a.forward(length)
a.pensize(30)
a.pencolor("white")
a.backward(length)
#出数总和
total=0
while total<20:
#玩家输入整数
b=turtle.Screen()
player_num=int(b.textinput("谁先到达20","请输入1~3范围的整数"))
print("玩家的数:",player_num)
a.pencolor("mistyrose")
a.forward(player_num*10)
total=total+player_num
print("总和",total)
if total==20:
print("玩家赢了!")
elif total>20:
print("玩家输了!")
else:
#电脑随机出整数
com_num=random.randint(1,3)
print("电脑出的数:",com_num)
a.pencolor("salmon")
a.forward(com_num*10)
total=total+player_num
print("总和",total)
if total==20:
print("电脑赢了!")
elif total>20:
print("电脑输了!")
else:
print("?????")
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn