Я сделал анкету или короткую и простую математическую викторину для развлечения с небольшой помощью других форумов.
У меня есть вопросы как функции, с ответами внутри них, например:
def q1():
print("What is 6 divided by 2?")
answer = str(input())
if answer == "3":
print("You have {} lives left".format(lives)) # displays the current lives (does not lose a life)
print("CORRECT!")
else:
lives -= 1 # loses a life
print("You have {} lives left".format(lives)) # displays the current lives (loses a life)
print("WRONG!")
q1()
У меня есть четыре из этих вопросов, и они все в одной функции:
def questions():
def q1():
print("What is 6 divided by 2?")
answer = str(input())
if answer == "3":
print("You have {} lives left".format(lives)) # displays the current lives (does not lose a life)
print("CORRECT!")
else:
lives -= 1 # loses a life
print("You have {} lives left".format(lives)) # displays the current lives (loses a life)
print("WRONG!")
q1()
time.sleep(2)
print()
def q2():
print("What is 6 multiplied by 2?")
answer = str(input())
if answer == "12":
print("You have {} lives left".format(lives)) # displays the current lives (does not lose a life)
print("CORRECT!")
else:
lives -= 1 # loses a life
print("You have {} lives left".format(lives)) # displays the current lives (loses a life)
print("WRONG!")
q2()
time.sleep(2)
print()
def q3():
print("What is 5 multiplied by 5?")
answer = str(input())
if answer == "12":
print("You have {} lives left".format(lives)) # displays the current lives (does not lose a life)
print("CORRECT!")
else:
lives -= 1 # loses a life
print("You have {} lives left".format(lives)) # displays the current lives (loses a life)
print("WRONG!")
q3()
time.sleep(2)
print()
def q4():
print("What is 20 divided by 2?")
answer = str(input())
if answer == "12":
print("You have {} lives left".format(lives)) # displays the current lives (does not lose a life)
print("CORRECT!")
else:
lives -= 1 # loses a life
print("You have {} lives left".format(lives)) # displays the current lives (loses a life)
print("WRONG!")
q4()
questions()
Мой полный код ^ выше ^
Когда я открываю интерактивное окно python, на экране ничего не отображается и не печатается.
Как мне напечатать вопросы определения и напечатать, если игрок ответил правильно или неправильно?