|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
如何给这段代码加入计时的模块(Python)
import time
print('-----------口算检测----------')
time.sleep(1)
print("注意:本次检测共十道0-100的口算题。累计答对六道为及格。每次输入完数值后请按'enter'以确定答案。")
time.sleep(1)
print('预祝您取的好成绩!')
time.sleep(1)
x = int(input('输入"1"以确定开始检测:'))
while x == 1:
a = int(input('请输入您想口算的算法(加法1减法2乘法3)'))
import random
times = 1
right = 0
z = 0
h = 0
if a == 1 or a == 2 or a == 3:
time.sleep(1)
input('请按"enter"开始检测:')
time.sleep(1)
while times < 11:
b = random.randint(1,100)
c = random.randint(1,100)
if a == 1:
print(b)
print('+')
print(c)
d = int(input('请输入您的答案:'))
time.sleep(0.5)
print('正确答案是:')
time.sleep(0.1)
print(b + c)
e = b + c
if d == e:
time.sleep(0.5)
print('恭喜您回答正确!')
right += 1
else:
print('回答错误!')
times += 1
if a == 2:
if b < c:
h = c
z = b
else:
z = c
h = b
print(h)
print('-')
print(z)
d = int(input('请输入您的答案:'))
time.sleep(0.5)
print('正确答案是:')
time.sleep(0.1)
print(h - z)
e = h - z
if d == e:
time.sleep(0.5)
print('恭喜您回答正确!')
right += 1
else:
print('回答错误!')
times += 1
if a == 3:
w = random.randint(1,10)
q = random.randint(1,100)
print(w)
print('*')
print(q)
d = int(input('请输入您的答案:'))
time.sleep(0.5)
print('正确答案是:')
time.sleep(0.1)
print(w * q)
e = w * q
if d == e:
time.sleep(0.5)
print('恭喜您回答正确!')
right += 1
else:
print('回答错误!')
times += 1
else:
print('本次测试结束!')
time.sleep(0.5)
print('您答对的题数是:')
time.sleep(0.5)
print(right)
if 3 < right < 6:
time.sleep(0.5)
print('差一点点就及格啦,继续努力吧!')
elif right < 4:
time.sleep(0.5)
print('这次你没能及格,还需努力呦!')
elif 6 <right < 10:
time.sleep(0.5)
print('恭喜你及格啦,继续努力吧!')
elif right > 9:
time.sleep(0.5)
print('恭喜你,满分哦!')
time.sleep(1)
print('拜拜~~~')
x = int(input('输入"1"再次检测:'))
else:
print('输入错误!请重启程序!')
else:
print('再见!')
|
|