我无法理解代码中的错误,为什么没有得到任何输出?
我已经彻底检查了我的代码,但仍然找不到任何错误。
当我试着在pycharm上运行它时,它什么也没做
import random
def ques():
name=input("What's your name?:")
print("Hi",name,"!")
choice=random.choice("+x")
finish=False
quesno=0
correctques=0
while finish == False:
if quesno<10|questno>=0:
no1=random.randrange(1,10)
no2=random.randrange(1,10)
print((no1),(choice),(no2))
ans=int(input("What's the answer?:"))
quesno=quesno+1
if choice==("+"):
realans=no1+no2
if ans==realans:
print("That's the correct answer!")
correctques=correctques+1
else:
print("That's incorrect!,the answer was",realans,"!")
if choice==("x"):
realans=no1*no2
if ans==realans:
print("That's the correct answer!")
correctques=correctques+1
else:
print("That's incorrect!,the answer was",realans,"!")
elif choice==("-"):
realans=no1-no2
if ans==realans:
print("That's the correct answer")
correctques=correctques+1
else:
print("That's incorrect!,the answer was",realans,"!")
else:
finish=True
else:
print("Good Job",name,"! You have finished the quiz")
您需要调用该函数。 在代码末尾,只需键入ques(),这将调用function,您应该能够获得输出
你跑了吗?将此添加到代码末尾
相关问题 更多 >
编程相关推荐