用户:
我是菜鸟2查看:0 回复:0 评论:0 创建时间:2021-07-24T16:09:19
【作品展示】

【作品介绍】
灵感来源于python第8课,操作很简单,按照上面提示就行了。
【作品源代码】
import random
import turtle
import time
print('欢迎使用CodeMao')
x = int(input('请输入您想挑战的范围,例如:0-100(输入100)'))
print('您已选择0-', x, '的范围')
y = int(input('请输入您想挑战的数量'))
z = str(input('请输入您想挑战的是加法还是减法?(只输入汉字,如果输的不对会默认减法,例如:加法)'))
score = 0
if (str('加法') == z):
print('挑战马上开始,请在5秒内作答')
for i in range(y):
print()
a = random.randint(0, x)
b = random.randint(0, x)
prompt = (((str(a) + '+') + str(b)) + '= ? ')
print(prompt)
start_time = time.time()
answer = int(input('请输入你的答案:'))
end_time = time.time()
if (end_time - start_time >= 5):
print('对不起,您已超时')
else:
if (answer == a + b):
print('回答正确')
score = (score + 1)
else:
print('回答错误')
break
else:
print('挑战马上开始,请在5秒内作答')
for i in range(y):
print()
a = random.randint(0, x)
b = random.randint(a, x)
prompt = (((str(b) - '-') - str(a)) + '= ? ')
print(prompt)
start_time = time.time()
answer = int(input('请输入你的答案:'))
end_time = time.time()
if (end_time - start_time >= 5):
print('对不起,您已超时')
else:
if (answer == b - a):
print('回答正确')
score = (score + 1)
else:
print('回答错误')
print('继续努力吧')
break
if (y == score):
print((str('恭喜您获得称号:') + (z + str('小能手'))))
pen = turtle.Pen()
pen.dot(100, "gold")
pen.dot(90, "orange")
pen.dot(80, "gold")
pen.dot(70, "orange")
pen.penup()
pen.goto(0, 10)
pen.fillcolor('red')
pen.shape("turtle")
pen.stamp()
pen.goto((-25), (-17))
pen.write((z + str('小能手')))
pen.hideturtle()
turtle.done()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn