我的问题是,当你回答一个问题时,while循环会一直重复,直到所有10个问题都被回答但是这只是为了让答案正确 为了弄错,它永远循环
正确答案:
locus match start end subset pos region
uce-3280 uce-3280_p1 269 388 uce-3280 222 no
uce-6620 uce-6620_p1 297 416 uce-6620 198 no
uce-6620 uce-6620_p1 297 416 uce-6620 300 yes
uce-432 uce-432_p2 328 447 uce-432 205 no
uce-432 uce-432_p1 268 387 uce-6459 207 no
uce-6459 uce-6459_p1 210 329 uce-6459 275 yes
uce-6459 uce-6459_p1 210 329 uce-6459 288 yes
uce-6459 uce-6459_p1 210 329 uce-374 373 no
uce-374 uce-374_p2 509 628 uce-3393 327 no
uce-374 uce-374_p1 449 568 uce-3393 416 no
uce-3393 uce-3393_p1 439 558 uce-3393 712 no
uce-3393 uce-3393_p1 439 558 uce-1200 416 yes
uce-3393 uce-3393_p1 439 558 uce-805 397 yes
uce-1200 uce-1200_p3 341 460 uce-627 326 no
uce-805 uce-805_p1 333 452 uce-2299 340 no
uce-627 uce-627_p1 396 515 uce-2126 481 no
uce-2299 uce-2299_p1 388 507 uce-5427 562 yes
uce-2126 uce-2126_p1 323 437 uce-5427 711 no
uce-5427 uce-5427_p1 509 628 uce-5893 242 no
uce-5427 uce-5427_p1 509 628 uce-5893 330 no
uce-5893 uce-5893_p1 477 582 uce-5893 398 no
错误答案:
what is
7 * 2
Answer here: 14
you got the answer right,well done
you got the answer right,well done
you got the answer right,well done
you got the answer right,well done
you got the answer right,well done
you got the answer right,well done
you got the answer right,well done
you got the answer right,well done
you got the answer right,well done
you got the answer right,well done
Welldone you have answered all 10 questions and managed to get correct: 10
press enter to exit
并且这种情况一直在重复,并且它不会结束
这是程序的代码
wrong
wrong
wrong
答案 0 :(得分:0)
这就是你想要的:
import random
correct,number,left,right = 0,0,random.randint(6,10),random.randint(1,5)
add =(left+right)
sub =(left-right)
mul =(left*right)
StrAdd =("+")
StrSub =("-")
StrMul =("*")
StrOp=StrAdd,StrSub,StrMul
StrRandOp=random.choice(StrOp)
print("\n\nwhat is\n",left,"",StrRandOp,"",right,)
given = float(input("\nAnswer here: "))
while number < 10:
if given == add:
print("you got the answer right,well done")
correct=correct+1
elif given == sub:
print("you got the answer right,well done")
correct=correct+1
elif given == mul:
print("you got the answer right,well done")
correct=correct+1
else:
print("wrong")
number = number + 1
print("""Welldone you have answered all 10 questions and managed to get
correct:""", correct)
input("press enter to exit")
当您想要迭代特定次数时,最好使用for
循环:
for number in range(0,10,1):
print "sth"