我有⼀个作业要做,我真的需要⼀个解决⽅案.从昨天开始,我⼀直在尝试这样做,但是我不知道怎么做.
好吧,我不知道该如何限制⽐赛时间.我正在搜索stackoverflow,但没有发现任何有⽤的东西.请帮我.
**这是我到⽬前为⽌所做的.我从SYSS.STDER的答案中尝试了代码,但是由于30秒结束时,游戏也应该结束,因此它不能正常⼯作,但是在此代码中,当我键⼊最后⼀个字符时,游戏结束了.
循环不会停⽌,直到完成为⽌,我们发现我们已逾期.任务需要随着时间流逝⽽不断地进⾏.
max_time =30
start_time = time.time() # remember when we started
while (time.time() - start_time) < max_time:
response = "a" # the variable that will hold the user's response
c = "b" #the variable that will hol
父亲节快乐的图片酸菜鱼怎么做好吃d th
人教版四年级上册语文教学计划e character the user should type
score = 0
number = 0
c = random.choice(string.ascii_lowercase + string.digits)
print(c)
邢昭林 照片number = number + 1
response = input("Type a letter or a number: ") #get the user's response
if response == c and (time.time() - start_time) < max_time:
代悦# if the response from the previous loop matches the character
# from the previous loop, increase the score.
score = score + 1
发布评论