Esempio n. 1
0
def quest(co, l1):
    name = l1[1]
    msg = qt.question(name)
    for i in msg:
        ms = i + '#.#'
        co.send(ms.encode())
    time.sleep(0.1)
    co.send(b'O#K')
Esempio n. 2
0
 def __init__(self, path):
     tree = ET.parse(join(path, 'info.xml'))
     root = tree.getroot()
     self.que_list = []
     for que in root.findall(words.question):
         self.que_list.append(question(join(path, que.get(words.name))))
     
     self.que_list.sort() 
Esempio n. 3
0
def getInput():
    inp = input()
    inpNoPunct = inp.translate(str.maketrans('', '', string.punctuation))
    inpLower = inpNoPunct.lower()
    if isIn("?", inp):
        print(question.question(inpLower))
    if isIn(".", inp):
        statement.statement(inpLower)
Esempio n. 4
0
def create():
    post = question.question()
    Question.clear()
    Question.append(post[0])
    Question.append(post[1])
    Question.append(post[2])
    return render_template('create.html',
                           post1=post[0],
                           post2=post[1],
                           post3=post[2])
Esempio n. 5
0
def insertQuestion():
    conn = db_ques.question(con_db)
    data = request.json
    sheet = ques.question(
        1,
        data["content"],
        data["ansA"],
        data["ansB"],
        data["ansC"],
        data["ansD"],
        data["ansCorrect"],
        data["swapAns"],
        data["idOfTest"],
    )
    result = conn.insert(sheet)
    return jsonify({"data": result}), 200
Esempio n. 6
0
def updateQuestion():
    conn = db_ques.question(con_db)
    data = request.json
    sheet = ques.question(
        data['idOfQuestion'],
        data["content"],
        data["ansA"],
        data["ansB"],
        data["ansC"],
        data["ansD"],
        data["ansCorrect"],
        data["swapAns"],
        data["idOfTest"],
    )
    result = conn.update(sheet)
    return jsonify({"data": result}), 200
Esempio n. 7
0
    obj = util()
    if obj.isLogin():
        print("您已经登陆")
    else:
        account = raw_input('请输入你的用户名\n>  ')
        secret = raw_input("请输入你的密码\n>  ")
        obj.login(secret, account)

    begin = int(time.time())
    print u"正在抓取个人您知乎数据...."
    #获取个人主页token
    token = obj.getToken()
    print u"获取个人主页token:", token

    obj_topic = topic.topic(obj.session)
    obj_question = question.question()
    obj_answer = answer.answer()

    # topic_id = '19551432'
    # questions=obj_question.getQuestionsByXHR(topic_id,'hot',0,3200.29677322)
    # for question in questions:
    #     print question[1]
    #questions = obj_question.getQuestionsByTopicId('19551432', 'hot')
    # topic_id='19551432'
    #
    # questions = obj_question.getQuestionsByTopicId(topic_id)
    #
    # # 创建话题文件夹(需要查表)
    # obj.cursor.execute("SELECT NAME FROM TOPIC WHERE LINK_ID = %s", int(topic_id))
    # result = obj.cursor.fetchone()
    # topic_name = result[0].encode('utf-8') #编译成中文
Esempio n. 8
0
from question import question

question_prompt = [
    "what is my name? \n (a) Kiriyan \n(b) Tha \n(c) Bala\n \n" ,
    "what is my age? \n (a) 20 \n(b) 30 \n(c) 40 \n\n" ,
    "what is my location ? \n (a) Glasgow \n(b) London \n(c) NYC\n\n"
]

questions = [               
    question(question_prompt[0], "a"), # create 1st question object, 
                                       # call 'question' class init function in the question.py file.
                                       # call with values from above list.
    
    question(question_prompt[1], "b"), # create 2nd question object
    question(question_prompt[2], "a"), # create 3rd question object
]



def run_test(questions):
    score = 0
    for question in questions:
        answer = input(question.prompt)
        if answer == question.answer:
             score = score + 1
    print("You got " + str(score) + "/" + str(len(questions)) + " Correct")


run_test(questions)
Esempio n. 9
0
from question import question
question_prompt = [
    "What color are apples:\n a-Red \n b-Purple \n c-Orange\n",
    "What color are bananas:\n a-Pink \n b-Magenta \n c-Yellow\n",
    "What color are strawberry:\n a-Yellow \n b-Red \n c-Blue\n",
]

questions = [
    question(question_prompt[0], 'a'),
    question(question_prompt[1], 'c'),
    question(question_prompt[2], 'b')
]


def run_test(questions):
    score = 0
    for question in questions:
        answer = input(question.prompt)
        if answer == question.answer:
            score += 1
    print('Your score: ' + str(score))


run_test(questions)
Esempio n. 10
0
wait_clear(1)
bit_sad.bit_sad()
wait_clear(1)
small_neutral.small_neutral()
wait_clear(1)
very_sad.very_sad()
wait_clear(1)
neutral.neutral()
wait_clear(1)
grin.grin()
wait_clear(1)
cross.cross()
wait_clear(1)
tick.tick()
wait_clear(1)
question.question()
wait_clear(1)
speak1.speak1()
wait_clear(0.1)
speak2.speak2()
wait_clear(0.1)
speak1.speak1()
wait_clear(0.1)
speak2.speak2()
wait_clear(0.1)
speak1.speak1()
wait_clear(0.1)
speak2.speak2()
wait_clear(0.1)
speak1.speak1()
wait_clear(0.1)
Esempio n. 11
0
from question import question

question_prompt = [
    "apple colors?\n (a) Red/Gren\n(b) Purple\n(c) Orange\n\n",
]

questions = [
    question(question_prompt[0], "a"),
]


def run_test(questions):
    score = 0
    for question in questions:
        answer = input(question.prompt)
        if answer == question.answer:
            score += 1
    print("You got " + str(score) + "/" + str(len(questions)) + " correct")


run_test(questions)
Esempio n. 12
0
def echo_socket(ws):
    while True:
        message = ws.receive()
        mes = json.loads(message)
        res = question(mes)
        ws.send(res)
Esempio n. 13
0
        if stripped.startswith('#'):
            continue

        # pull out the fields for this question
        fields = stripped.split(',')
        if len(fields) < 4:
            print("ignoring line %d: %d fields" % (lineNum, len(fields)))
            continue

        xname = fields[0].strip()
        qnum = fields[1].strip()
        qname = fields[2].strip()
        role = fields[3].strip()

        # print out the information for this question
        q = question(qname, role, qnum, opts.qdir)
        sum = q.summary()

        if not heading:
            print "## " + q.heading(False)
            print "-- " + q.heading(True)
            heading = True

        # prefixed number may be line count or question number
        prefix = "   "
        if outX:
            prefix = "%2d " % (q.printExam(pager))
        elif qnum != "":
            prefix = "%2s " % (qnum)
        print prefix + sum
Esempio n. 14
0
        "Lets play are you ready : enter either yes or no.\n difficulty : Choose easy, medium or Hard.\n exit : ctrl+Z.\n Questions: 5 on each set of difficulty.\n score: total score earned.\n"
    )
    exit()

#  easy questions
questions_prompt_easy = [
    "- I am always on my way, but never arrive today. What am I?\n\n",
    "- What side of the cat has the most fur?\n\n",
    "- What has a tongue but does not eat or speak?\n\n",
    "- You buy me to eat, but never eat me. What am I?\n\n",
    "- What has a neck but no head?\n\n"
]

# answer for the easy questions
questions_easy = [
    question(questions_prompt_easy[0], "tommorow"),
    question(questions_prompt_easy[1], "outside"),
    question(questions_prompt_easy[2], "shoe"),
    question(questions_prompt_easy[3], "silverware"),
    question(questions_prompt_easy[4], "bottle"),
]

# medium  questions
questions_prompt_medium = [
    "- What do you call a three humped camel?\n\n\n",
    "- What can fly without wings?\n\n\n",
    "- What comes down but never goes up?\n\n\n",
    "- On which day of the year does fewer people die?\n\n\n",
    "- I am not alive but I can die what am I?\n\n\n"
]
Esempio n. 15
0
    def showSomething(self):
        for i in range(self.start, self.stop, 1):
            self.quesID = self.q[i].get('quesId')
            self.courseID = self.q[i].get('subId')
            self.question = self.q[i].get('question')
            self.ansA = self.q[i].get('ansA')
            self.ansB = self.q[i].get('ansB')
            self.ansC = self.q[i].get('ansC')
            self.ansD = self.q[i].get('ansD')
            self.correctAns = self.q[i].get('correctAnswer')
            self.level = self.q[i].get('level')
            self.username = self.q[i].get('teacherUsername')
            self.comment = self.q[i].get('comment')

            self.selectQuestion = question(self.quesID, self.courseID,
                                           self.question, self.ansA, self.ansB,
                                           self.ansC, self.ansD,
                                           self.correctAns, self.level,
                                           self.username)

            font = QtGui.QFont()
            font.setPointSize(14)

            self.quesLabel = QtWidgets.QLabel(self.Form)
            self.quesLabel.setGeometry(QtCore.QRect(190, 210 + self.y, 161,
                                                    51))
            self.quesLabel.setFont(font)
            self.quesLabel.setObjectName("quesLabel")

            self.courseIdLabel = QtWidgets.QLabel(self.Form)
            self.courseIdLabel.setGeometry(
                QtCore.QRect(190, 240 + self.y, 131, 51))
            self.courseIdLabel.setFont(font)
            self.courseIdLabel.setObjectName("courseIdLabel")

            self.statusLabel = QtWidgets.QLabel(self.Form)
            self.statusLabel.setGeometry(
                QtCore.QRect(190, 270 + self.y, 161, 51))
            self.statusLabel.setFont(font)
            self.statusLabel.setObjectName("statusLabel")

            self.commentLabel = QtWidgets.QLabel(self.Form)
            self.commentLabel.setGeometry(
                QtCore.QRect(450, 210 + self.y, 161, 51))
            self.commentLabel.setFont(font)
            self.commentLabel.setObjectName("commentLabel")

            self.displayQuesId = QtWidgets.QLabel(self.Form)
            self.displayQuesId.setGeometry(
                QtCore.QRect(320, 210 + self.y, 131, 51))
            self.displayQuesId.setFont(font)
            self.displayQuesId.setObjectName("displayQuesId")

            self.displayCourseId = QtWidgets.QLabel(self.Form)
            self.displayCourseId.setGeometry(
                QtCore.QRect(320, 240 + self.y, 241, 51))
            self.displayCourseId.setFont(font)
            self.displayCourseId.setObjectName("displayCourseId")

            self.displayStatus = QtWidgets.QLabel(self.Form)
            self.displayStatus.setGeometry(
                QtCore.QRect(320, 270 + self.y, 241, 51))
            self.displayStatus.setFont(font)
            self.displayStatus.setObjectName("displayCourseId")

            self.editButton = QtWidgets.QPushButton(self.Form)
            self.editButton.setGeometry(
                QtCore.QRect(980, 225 + self.y, 131, 61))
            self.editButton.setFont(font)

            self.deleteButton = QtWidgets.QPushButton(self.Form)
            self.deleteButton.setGeometry(
                QtCore.QRect(980, 275 + self.y, 131, 61))
            self.deleteButton.setFont(font)

            self.displayComment = QtWidgets.QTextBrowser(self.Form)
            self.displayComment.setGeometry(
                QtCore.QRect(530, 230 + self.y, 431, 100))
            self.displayComment.setObjectName("displayComment")

            self.a.append(self.quesLabel)
            self.a.append(self.displayQuesId)
            self.a.append(self.displayCourseId)
            self.a.append(self.courseIdLabel)
            self.a.append(self.statusLabel)
            self.a.append(self.displayStatus)
            self.a.append(self.commentLabel)
            self.a.append(self.deleteButton)
            self.a.append(self.nextButton)
            self.a.append(self.displayComment)
            self.a.append(self.editButton)

            for x in self.a:
                x.show()

            self.editButton.clicked.connect(
                lambda checked, arg=self.selectQuestion: self.edit(arg))
            self.deleteButton.clicked.connect(
                lambda checked, arg=self.selectQuestion: self.reject(arg))

            self.quesLabel.raise_()
            self.displayQuesId.raise_()
            self.courseIdLabel.raise_()
            self.displayCourseId.raise_()
            self.statusLabel.raise_()
            self.displayStatus.raise_()
            self.commentLabel.raise_()
            self.deleteButton.raise_()
            self.displayComment.raise_()
            self.editButton.raise_()
            self.nextButton.raise_()

            self.retranslateUi2(self.Form)

            self.displayQuesId.setText(self.quesID)
            self.displayCourseId.setText(self.courseID)
            self.displayStatus.setText("REJECTED")
            self.displayComment.setText(self.comment)

            self.y += 150

            if self.start == 0:
                self.backButton.hide()

            if i == self.stop - len(self.q):
                break

            if i == len(self.q) - 1:
                self.nextButton.hide()
                break
Esempio n. 16
0
from question import question

question_prompt = [
    "what is my name? \n (a) Kiriyan \n(b) Tha \n(c) Bala\n \n",
    "what is my age? \n (a) 20 \n(b) 30 \n(c) 40 \n\n",
    "what is my location ? \n (a) Glasgow \n(b) London \n(c) NYC\n\n"
]

questions = [
    question(question_prompt[0], "a"),
    question(question_prompt[1], "b"),
    question(question_prompt[2], "a"),
]


def run_test(questions):
    score = 0
    for question in questions:
        answer = input(question.prompt)
        if answer == question.answer:
            score = score + 1
    print("You got " + str(score) + "/" + str(len(questions) + " Correct"))

    run_test(questions)

    #Hello2 - cloned repo commit.
Esempio n. 17
0
    def showSomething(self):
        print(str(self.start) + "start")
        print(str(self.stop) + "stop")
        self.length = len(self.q)
        print(str(self.length))

        for i in range(self.start, self.stop, 1):

            self.quesID = self.q[i].get('quesId')
            self.courseID = self.q[i].get('subId')
            self.question = self.q[i].get('question')
            self.ansA = self.q[i].get('ansA')
            self.ansB = self.q[i].get('ansB')
            self.ansC = self.q[i].get('ansC')
            self.ansD = self.q[i].get('ansD')
            self.correctAns = self.q[i].get('correctAnswer')
            self.level = self.q[i].get('level')
            self.username = self.q[i].get('teacherUsername')

            self.selectQuestion = question(self.quesID, self.courseID,
                                           self.question, self.ansA, self.ansB,
                                           self.ansC, self.ansD,
                                           self.correctAns, self.level,
                                           self.username)

            font = QtGui.QFont()
            font.setPointSize(14)

            self.quesLabel = QtWidgets.QLabel(self.Form)
            self.quesLabel.setGeometry(QtCore.QRect(190, 210 + self.y, 161,
                                                    51))
            self.quesLabel.setFont(font)
            self.quesLabel.setObjectName("quesLabel")

            self.displayQuesId = QtWidgets.QLabel(self.Form)
            self.displayQuesId.setGeometry(
                QtCore.QRect(360, 210 + self.y, 131, 51))
            self.displayQuesId.setFont(font)
            self.displayQuesId.setObjectName("displayQuesId")

            self.courseIdLabel = QtWidgets.QLabel(self.Form)
            self.courseIdLabel.setGeometry(
                QtCore.QRect(510, 210 + self.y, 131, 51))
            self.courseIdLabel.setFont(font)
            self.courseIdLabel.setObjectName("courseIdLabel")

            self.displayCourseId = QtWidgets.QLabel(self.Form)
            self.displayCourseId.setGeometry(
                QtCore.QRect(660, 210 + self.y, 241, 51))
            self.displayCourseId.setFont(font)
            self.displayCourseId.setObjectName("displayCourseId")

            self.usernameLabel = QtWidgets.QLabel(self.Form)
            self.usernameLabel.setGeometry(
                QtCore.QRect(190, 260 + self.y, 251, 51))
            self.usernameLabel.setFont(font)
            self.usernameLabel.setObjectName("usernameLabel")

            self.displayUsername = QtWidgets.QLabel(self.Form)
            self.displayUsername.setGeometry(
                QtCore.QRect(460, 260 + self.y, 371, 51))
            self.displayUsername.setFont(font)
            self.displayUsername.setObjectName("displayTeachName")

            self.viewButton = QtWidgets.QPushButton(self.Form)
            self.viewButton.setGeometry(
                QtCore.QRect(940, 220 + self.y, 211, 81))
            self.viewButton.setFont(font)

            self.a.append(self.quesLabel)
            self.a.append(self.displayQuesId)
            self.a.append(self.displayCourseId)
            self.a.append(self.usernameLabel)
            self.a.append(self.viewButton)
            self.a.append(self.courseIdLabel)
            self.a.append(self.displayUsername)

            for x in self.a:
                x.show()

            self.viewButton.clicked.connect(
                lambda checked, arg=self.selectQuestion: self.viewQuestion(arg
                                                                           ))

            self.quesLabel.raise_()
            self.displayQuesId.raise_()
            self.courseIdLabel.raise_()
            self.displayCourseId.raise_()
            self.usernameLabel.raise_()
            self.displayUsername.raise_()
            self.viewButton.raise_()
            self.nextButton.raise_()

            self.retranslateUi2(self.Form)

            self.displayQuesId.setText(self.quesID)
            self.displayCourseId.setText(self.courseID)
            self.displayUsername.setText(self.username)

            self.y += 150

            if self.start == 0:
                self.backButton.hide()

            if i == len(self.q) - 1:
                self.nextButton.hide()
                break
Esempio n. 18
0
from question import question
sample = [
    "what is the colour of an orange \n(A). orange \n(B). blue\n(C). Purple \n your answer: \n",
    "What is 2+2?  \n(A). 4 \n(B). 0\n(C). 1 \n your answer: \n",
    "How many months do we have in a year \n(A).12 \n(B). 1\n(C). 4\n your answer: \n "
]

question1 = [
    question(sample[0], "a"),
    question(sample[1], "a"),
    question(sample[2], "a")
]


def run_question(question):
    score = 0
    for question in question:
        answer = input(question.promt)
        if answer == question.answer:
            score = score + 1
    print("your score is " + str(score))


run_question(question1)
Esempio n. 19
0
question_prompts = [
    "\n1. ¿En que continente esta El Ecuador?\n(a) Asia\n(b) America\n(c) Europa\n\n",
    "2. ¿Cual es el oceano mas grande?\n(a) Oceano Pacifico\n(b) Oceano Atlantico\n(c) Oceano Indico\n\n",
    "3. ¿Cual es el pais mas grande del mundo?\n(a) China\n(b) Estados Unidos\n(c) Rusia\n\n",
    "4. ¿Cual es la principal ciudad de los rascacielos?\n(a) Tokyo\n(b) Hong Kong\n(c) Nueva York\n\n",
    "5. ¿Quien gano el mundial de 2014?\n(a) Alemania\n(b) Francia\n(c) Argentina\n\n",
    "6. ¿Cual es el metal mas caro del mundo?\n(a) Oro\n(a) Platino\n(c) Rodio\n\n",
    "7. ¿Cual es la quinta provincia de panama?\n(a) Herrera\n(b) Darien\n(c) Colon\n\n",
    "8. ¿Quien escribio el himno nacional de Panama?\n(a) Jeronimo de la Ossa\n(b) Santos jorge amatrian\n(c) Manuel Amador Guerrero\n\n",
    "9. ¿Quien fue el primer presidente de Panama?\n(a) Dr. Manuel Amador Guerrero\n(b) Torrijos Carter\n(c) Jeronimo de Ossa\n\n",
    "10. ¿En que año fue inagurado el Canal de Panama?\n(a) 1999\n(b) 1948\n(c) 1914\n\n",
]

questions = [
    question(question_prompts[0], "b"),
    question(question_prompts[1], "a"),
    question(question_prompts[2], "c"),
    question(question_prompts[3], "b"),
    question(question_prompts[4], "a"),
    question(question_prompts[5], "c"),
    question(question_prompts[6], "b"),
    question(question_prompts[7], "a"),
    question(question_prompts[8], "a"),
    question(question_prompts[9], "c"),
]


def run_test(questions):
    score = 0
    for question in questions:
Esempio n. 20
0
# the module function is to build a module to build subject, and set individually contribution

# create a questions class, it's convenient to create subject having same attribution
# beforeahead to create a promt and answer to the questions
# build a def to test the function

from question import question

# describe the whole content
questions_prompt = [
    ('the color of apple is ', 'a = red','b = yellow'),
    ('the color of banana is ', 'a = red', 'b = yellow')
]

# build an object values to the object class
questions = [
    question(questions_prompt[0],'a'),
    question(questions_prompt[1],'b')
]

def run_test(questions):
    for question in questions: # each subject for whole modul
        scorr = 0
        answer = input(question.prompt) # input the contribution for each subject
        if answer == question.answer:
            scorr = scorr + 1
        print(scorr)

run_test(questions)
Esempio n. 21
0
""" Main Module"""
from config_module import config
from create_tables import main as create_tables
from etl import main as etl
from load_csv_files import main as load_csv_file
from question import main as question
from sql_queries.oltp import create_table_queries, drop_table_queries
"""
 3 thins done in this project:
 1- Creating original database and tables
 2- Loading csv files data to original table
 3- Creating new database and tables which is a fact and multiple dimension tables through sql
 queries for transformation in etl process. Queries can be check in sql_queries.oltp module
"""

if __name__ == '__main__':
    obj = config.resolve()
    create_tables(obj, "OLTP_DB", create_table_queries, drop_table_queries)
    load_csv_file()
    etl()
    question()
Esempio n. 22
0
def main():
    """Iss check status engine. 
		
	This function, when executed from the command line with the appropriate
	arguments will retrieve from the web and display certain informations
	pertaining to the ISS.
	
	For more detailed notes on usage, please see the user manual located
	two levels up the directory and inside of the docs/ subdirectory.
	
	The command line invocation for this function requires at least one
	variable command line argument and up to three depending on choices
	made by the user.
	
	Command line options and their resulting behavior are described below.
	
	1. 'loc' - provides the current location of the ISS in
	(latitude, longitude)
	
	2. 'people' - provides the current crew roster of the ISS.
	
	3. 'pass [latitude] [longitude]' - provides the time and duration of
	flyover by the ISS for the given [latitude] and [longitude] user input
	variables. [latitude] is constrained to be between -90 and 90 degrees
	whereas [longitude] is constrained to be between -180 and 180 degrees.
	
	The collection and formatting of these informations is handled by the
	question class whose details can be found in question.py in the
	same subdirectory as this file."""

    # If there were no command line arguments, error out

    if len(sys.argv) < 2:

        print(
            "Error: Command line option must follow program invocation. Please provide one of the following keywords as a command line argument to this program: 'loc', 'pass', or 'people'. Please see the user manual for further information.\n"
        )

        return

# Take in the command line arguments

    opt = sys.argv[1]

    if len(sys.argv) > 2:

        args = [arg for arg in sys.argv[2:]]

    else:

        args = []

# Let the user know they have successfully entered the program

    print("\nWelcome to the ISS status check engine!\n")

    # Initiate an instance of the question class
    ## The instance of the question class
    query = question()

    # Have the question class check the input for correctness

    query.check_input(opt, args)

    # If the input is bad query.exit will be set to 1, exit as such
    # No need for an error message, query will have already handled that

    if query.exit > 0:

        return


# Have the question class respond to the request posed by the input

    query.respond()

    # Let the user know they have exited the program successfully

    print("Thank you for using the ISS status check engine!\n")
Esempio n. 23
0
listOfQuestions = []
listOfTests = []
listOfModules = []
listOfLecturers = []
listOfStudents = []
listOfLessons = []

with open("data/questions.txt") as questionsText:
    temp = []
    for line in questionsText:
        x = []
        x = line.split(";")
        x[-1] = x[-1].rstrip()
        temp.append(x)
    for questions in temp:
        y = question(questions[0],questions[1],questions[2],questions[3])
        listOfQuestions.append(y)
    
with open("data/tests.txt") as testsText:
    temp = []
    for line in testsText:
        x = []
        x = line.split(";")
        x[-1] = x[-1].rstrip()
        temp.append(x)
    for tests in temp:
        y = test(tests[0],tests[1],tests[2])
        listOfTests.append(y)
        
with open("data/modules.txt") as modulesText:
    temp = []
Esempio n. 24
0
# Building a multiple choice quiz
from question import question
question_prompts = [
    "What color are apples?\n(a) Red/Green\n(b) Purple\n(c) Orange\n\n",
    "What color are banana?\n(a) Teal\n(b) Magenta\n(c) Yellow\n\n",
    "What color are strawberries?\n(a) Yellow\n(b) Red\n(c) Blue\n\n"
]

questions_template = [
    question(question_prompts[0], "a"),
    question(question_prompts[1], "c"),
    question(question_prompts[2], "b")
]


def run_test(questions):
    score = 0
    for question in questions:
        answer = input(question.prompt)
        if answer == question.answer:
            score += 1
    print("You got " + str(score) + "/" + str(len(questions)) + " correct")


run_test(questions_template)
Esempio n. 25
0
#buiding a multipl choice quiz
from question import question
question_prompts = [
    'what color are apples?\n(a) Red/Green\n(b) Purple\n(c) Orange\n\n',
    'what color are Bananas?\n(a) Teal\n(b) Magenta\n(c) Yellow\n\n',
    'what color are strawberries?\n(a) Red\n(b) Yellow\n(c) Blue\n\n',
]

questions = [
    question(question_prompts[0], 'a'),
    question(question_prompts[1], 'c'),
    question(question_prompts[2], 'a'),
]


def run_test(questions):
    score = 0
    for question in questions:
        answer = input(question.prompt)
        if answer == question.answer:
            score += 1
    print('You got', str(score), '/', str(len(questions)), 'correct')


run_test(questions)