Exemplo n.º 1
0
def main():
    first = Question()
    first.setText("Who was the inventor of Python?")
    first.setAnswer("Guido van Rossum")

    second = ChoiceQuestion()
    second.setText("In which country was the inventor of Python born?")
    second.addChoice("Australia", False)
    second.addChoice("Canada", False)
    second.addChoice("Netherlands", True)
    second.addChoice("United States", False)

    third = NumericQuestion()
    third.setText("How much is 1 + 1")
    third.setAnswer("2")

    fourth = FillInQuestion()
    fourth.setText("The inventor of Python was _____")
    fourth.setText4("The inventor of Python was")
    fourth.setAnswer("Guido van Rossum")

    fifth = MultiChoiceQuestion()
    fifth.setText("In which fruit is red?")
    fifth.addMultiChoice("Apple", True)
    fifth.addMultiChoice("Orange", False)
    fifth.addMultiChoice("Tomato", True)
    fifth.addMultiChoice("guava", False)

    #presentQuestion(first)
    #presentQuestion(second)
    present3Question(third)
    present4Question(fourth)
    present5Question(fifth)
def main() :
   first = Question()
   first.setText("Who was the inventor of Python?")
   first.setAnswer("Guido van Rossum")

   second = ChoiceQuestion()
   second.setText("In which country was the inventor of Python born?")
   second.addChoice("Australia", False)
   second.addChoice("Canada", False)
   second.addChoice("Netherlands", True)
   second.addChoice("United States", False)

   presentQuestion(first)
   presentQuestion(second)
##
#  This program shows a simple quiz with one question.
#

from questions import Question
from choicequestion import ChoiceQuestion

# Create the question and expected answer.
q = Question()
q.setText("Who is the inventor of Python?")
q.setAnswer("Guido van Rossum")

# Display the question and obtain user's response.
q.display()
response = input("Your answer: ")
print(q.checkAnswer(response))

cq = ChoiceQuestion()
cq.setText('Test question1')
cq.addText(' new text')
cq.setAnswer('2')
print(cq.checkAnswer('2'))
Exemplo n.º 4
0
##
#  This program shows a simple quiz with one question.
#

from questions import Question

# Create the question and expected answer.
q = Question()
q.setText("Who is the inventor of Python?")
q.setAnswer("Guido van Rossum")      

# Display the question and obtain user's response.
q.display()
response = input("Your answer: ")
print(q.checkAnswer(response))