Python时间限制

Python时间限制,第1张

Python时间限制

这是我的方法

import stringimport random import timeresponse = "a"   # the variable that will hold the user's responsec = "b"          #the variable that will hold the character the user should typescore = 0        #the variable that will hold the user's scorestart = time.time()         #the variable that holds the starting timeelapsed = 0      #the variable that holds the number of seconds elapsed.while elapsed < 30:         #while less than 30 seconds have elapsed    if response == c:       #if the response from the previous loop matches the character        score += 1          #from the previous loop, increase the score.    #c is a random character    c = random.choice(string.ascii_lowercase + string.digits)    print(c)    response = input("Type a letter or a number: ") #get the user's response    elapsed = time.time() - start #update the time elapsed


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/zaji/5668413.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存