コード例 #1
0
def load_questions():
    questions = []
    question_file = open("Questions.txt", "r")
    for line in question_file:
        question = line.strip("\n").split(",")
        questions.append(
            Question(question[0], question[1], question[2], question[3],
                     question[4]))
    question_file.close()
    return questions
コード例 #2
0
    def add_question(self, user_question, answer, lie_1, lie_2, user_category):
        new_question = []

        if user_question == "":
            self.status = "Don't be shy, what is your question?"
        new_question.append(user_question)

        if answer == "":
            self.status = "I NEED ANSWERS!!!!"
        new_question.append(answer)
        if lie_1 == "":
            self.status = "I NEED A LIE!!!!"
        new_question.append(lie_1)
        if lie_2 == "":
            self.status = "I NEED ANOTHER LIE!!!!"
        new_question.append(lie_2)

        if user_category == "Category":
            self.status = "Don't be shy, what is your category?"
        new_question.append(user_category)

        question = Question(new_question[0], new_question[1], new_question[2],
                            new_question[3], new_question[4])
        self.game.questions.append(question)
コード例 #3
0
question_prompts = [
    "Have you (or anyone in your family) ever \n(a) broken your arm/leg? \n(b) felt your arm/leg? \n(c) caught your arm/leg?\n\n",
    "Do you often \n(a)catch colds or the flu? \n(b) give colds or the flu? \n(c) have colds or the flue?\n\n",
    "I went to the library last week \n(a) to find a book. \n(b) to discuss business. \n(c) to imporve my English.\n\n",
    "She always loves \n(a) going to the store \n(b) go to the store \n(c) gone to the store\n\n",
    "In 1999, she \n(a) went to Egypt. \n(b) had gone to Egypt. \n(c) had went to Egypt.\n\n",
    "If you’d written earlier, I’d have known when you \n(a) will want to go on holiday. \n(b) would want to go on holiday. \n(c) wanted to go on holiday.\n\n",
    "How many eggs have we got? \n(a)They're no in the fridge. \n(b)Not too many \n(c)Not too much.\n\n",
    "We \n(a) can be able to be millionaires one day \n(b) will have to be millionaires one day \n(c) could be millionaires one day.\n\n",
    "He was fined by the police for driving too \n(a) fastly \n(b) speedy \n(c) fast.\n\n",
    "What are you doing? I \n(a) tried to find my watch! \n(b) am trying to find my watch! \n(c) have tried to find my watch!\n\n"
]

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


def run_test(questions):
    score = 0
    for question in questions:
コード例 #4
0
                nwz.send_reply_to(conn)
                players.append(Player(player_ID, c[1], conn))
                player_addresses.append(c[1])
                player_ID += 1
    else:
        sleep(1)
        if len(players) > 0:
            nwz.send_news_to(quiz_server, "Information", "Waiting for... " + str(MAX_PLAYERS -len(players)) + " players")
sleep (5)
questions = []

with open("questions.csv", 'r') as file:
    for line in file.readlines():
        line = line.split(',')
        if len(line) > 4:
            new_q = Question(line[0], line[1:5], line[5])
            questions.append(new_q)

nwz.send_news_to(quiz_server, "Information", "Quiz Starting")

while len(questions) > 0:
    current_q = random.choice(questions)
    sleep(1)
    nwz.send_news_to(quiz_server, "Question", current_q.question)
    sleep(2)
    nwz.send_news_to(quiz_server, "Answers", current_q.answers)
    answered = 0
    while answered < len(players):
        for p in players:
            message = nwz.wait_for_message_from(p.connection, wait_for_s=0)
            if message is not None:
コード例 #5
0
def knowing_me():

    user_name = input("Enter your name: ")
    user_name1 = "Kwame"

    question_prompts1 = [
        "What does " + user_name1 +
        " love to sleep in? \n(a)Pyjamas \n(b)Birthday suit",
        "What is " + user_name1 + "'s favourite food? \n(a)Rice \n(b)Emo tuo"
    ]

    question_prompts2 = [
        "What do you love to sleep in? \n(a)Pyjamas \n(b)Birthday suit\n",
        "What is your favourite food? \n(a)Rice \n(b)Emo tuo\n"
    ]

    print("Hello " + user_name +
          " my name is Bliss and I want to know how well you know " +
          user_name1 + "\n")

    test1 = [
        Question(question_prompts1[0], 'b'),
        Question(question_prompts1[1], "b"),
    ]

    test2 = [
        Question(question_prompts2[0], 'b'),
        Question(question_prompts2[1], "b"),
    ]

    while True:
        score = 0
        for question in test1:
            print(question.prompt)
            answer = input()
            if answer == question.answer:
                print('correct')
                score += 1
            else:
                print("wrong")
            if score == 2:
                print("You know " + user_name1 + " very well")

        print(
            "Hello " + user_name +
            "! You are welcome to the 'Knowing Me' Game."
            "\nWhy don't you also tell us a little about yourself and let's find out how well your friends know you\n"
        )

        user_name1 = user_name

        question_prompts1 = [
            "What does " + user_name1 +
            " love to sleep in? \n(a)Pyjamas \n(b)Birthday suit\n",
            "What is " + user_name1 +
            "'s favourite food? \n(a)Rice \n(b)Emo tuo\n"
        ]
        test1 = [
            Question(question_prompts1[0], 'b'),
            Question(question_prompts1[1], "b"),
        ]
        for question in test1:
            question.answer = input(question.prompt)

        user_name = input("Enter your name: ")
コード例 #6
0
            if (q.currentSample >= q.numSamples):
                self.running = False
                self.current_question += 1
                if (self.current_question >= len(self.questions)):
                    self.current_question = 0
                    qtext = '\n'.join(
                        wrap(
                            "Test Finished! Data will be saved to {0}. Press continue to exit!"
                            .format(self.filename), 40))
                    self.questions_text.set_text(qtext)
                    self.finished = True
                    self.save_data()

                else:
                    qtext = '\n'.join(
                        wrap(self.questions[self.current_question].text, 40))
                    self.questions_text.set_text(qtext)

    def save_data(self):
        with bz2.BZ2File(self.filename, 'w') as f:
            pickle.dump(self.questions, f)


if __name__ == "__main__":
    o1 = ["UP", "Steady", "Down"]
    o1 = ["x", "y"]
    o2 = ["a"]
    #o2 = ["Grape","Realease","Extend"]
    q = [Question(x + " " + y, [x, y], 5) for x in o1 for y in o2]
    ida = InteractiveDataAcquitter(1000, 500, "data/test_data10.bz2", q)
    ida.start()
コード例 #7
0
questionPrompts = [
    "__ Likes Authority   __ Enthusiastic        __ Sensitive Feelings      __ Likes Instructions \n",
    "__ Takes Charge      __ Takes Risks         __ Loyal                   __ Accurate \n",
    "__ Determined        __ Visionary           __ Calm,Even Keel          __ Consistent \n",
    "__ Enterprising      __ Very Verbal         __ Enjoys Routine          __ Predictable \n",
    "__ Competitive       __ Promoter            __ Dislikes Change         __ Practical \n",
    "__ Problem Solver    __ Enjoys Popularity   __ Gives In To Others      __ Factual \n",
    "__ Productive        __ Fun-Loving          __ Avoids Confrontations   __ Conscientious \n",
    "__ Bold              __ Likes Variety       __ Sympathetic             __ Perfectionist \n",
    "__ Decision Maker    __ Spontaneous         __ Nurturing               __ Detail-Oriented \n",
    "__ Persistent        __ Inspirational       __ Peacemaker              __ Analytical \n"
]

questions = [
    Question(questionPrompts[0], []),
    Question(questionPrompts[1], []),
    Question(questionPrompts[2], []),
    Question(questionPrompts[3], []),
    Question(questionPrompts[4], []),
    Question(questionPrompts[5], []),
    Question(questionPrompts[6], []),
    Question(questionPrompts[7], []),
    Question(questionPrompts[8], []),
    Question(questionPrompts[9], []),
]


def take_test(questions):
    score = [0, 0, 0, 0]
    currentScore = [0, 0, 0, 0]
コード例 #8
0
from Questions import Question

question_prompts = [
    "What color are Apples?\n(a) Red/Green\n(b) Violet\n(c) Orange\n\n",
    "What color are Bananas?\n(a) Red\n(b) Yellow\n(c) Indigo\n\n",
    "What color are Strawberries?\n(a) Yellow\n(b) Red\n(c) Magenta\n\n",
]
questions = [
    Question(question_prompts[0], "a"),
    Question(question_prompts[1], "b"),
    Question(question_prompts[2], "b"),
]


def run_tests(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_tests(questions)
コード例 #9
0
from Questions import Question
question_prompts = [
    "What is the square root of 121?\n(A) 15\n(B) 12\n(C) 11\n(D) 14\n\n",
    "What is 255/5 = ?\n(A) 21\n(B) 31\n(C) 41\n(D) 51\n\n",
    "What is 987-389 = ?\n(A) 598\n(B) 599\n(C) 600\n(D) 601\n\n",
    "Who is the main villain in Harry Potter?\n(A) Draco\n(B) Umbridge\n(C) Snape\n(D) Voldemort\n\n",
    "Who is the main villain in Final Fantasy 6?\n(A) Sephiroth\n(B) Kefka\n(C) Kuja\n(D) Ultimecia\n\n"
]

questions = [
    Question(question_prompts[0], "C"),
    Question(question_prompts[1], "D"),
    Question(question_prompts[2], "A"),
    Question(question_prompts[3], "D"),
    Question(question_prompts[4], "B"),
]


def run_test(questions):
    score = 0
    for question in questions:
        answer = input(question.prompt)
        if answer == question.answer:
            print("Correct!")
            score += 1
        else:
            print("Nope! the correct answer is: " + str(question.answer) +
                  "\n\n")
    print("Well done, you got " + str(score) + "/" + str(len(questions)) +
          " Correct")
コード例 #10
0
ファイル: app.py プロジェクト: admi4067/First_Python_Project
from Questions import Question
questionsP =[
"What is color is grass? \n(a)Green \n(b)Red\n(c)Blue",
"What is color is a bananna? \n(a)Green \n(b)Yellow\n(c)Blue"
]

questions = [
    Question(questionsP[0],"a"),
    Question(questionsP[1],"b"),
]
def ask_question(questions):
    for i in questions:
        answer = input(i.prompt +" ")
        if answer == i.answer:
            print("Yes That is right")

ask_question(questions)




コード例 #11
0
from Questions import Question
questions_prompts = [
    "Who is the creator of Java Programming Language?\n(a) Dennis Ritchie\n(b) BJarne\n(c) James Gosling\n\n",
    "Who is the creator of C Programming Language?\n(a) Dennis Ritchie\n(b) BJarne\n(c) James Gosling\n\n",
    "Who is the creator of C++ Programming Language?\n(a) Dennis Ritchie\n(b) BJarne\n(c) James Gosling\n\n",
    "Who is the creator of Python Programming Language?\n(a) Dennis Ritchie\n(b) Guido van Rossum\n(c) James Gosling\n\n",
    "Who is the creator of Perl Programming Language?\n(a) Larry Wall\n(b) BJarne\n(c) James Gosling\n\n",
    ]

questions = [
    Question(questions_prompts[0], "c"),
    Question(questions_prompts[1], "a"),
    Question(questions_prompts[2], "b"),
    Question(questions_prompts[3], "b"),
    Question(questions_prompts[4], "a"),
]


def check_ans(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.")

check_ans(questions)
コード例 #12
0
from Questions import Question

Question_prompt = [
    "What color are Oranges\na)Red\nb)Orange\nc)Black\n\n",
    "What color are Apples\na)Red\nb)Orange\nc)Green\n\n",
    "What color are Bananas\na)Red\nb)Orange\nc)Yellow\n\n"
]

Questions = [
    Question(Question_prompt[0], "b"),
    Question(Question_prompt[1], "a"),
    Question(Question_prompt[2], "c")
]


def run_test(Questions):
    score = 0
    for question in Questions:
        answer = input(print(question.prompt))

        if answer == question.answer:
            score = score + 1

    print("You have got " + str(score) + " out of " + str(len(Questions)))


run_test(Questions)
コード例 #13
0
from Questions import Question

question_prompts = [
    "How many sequences are present in AC - Unity?\n(a) 11\n(b) 3\n(c) 8\n(d) 17\n\n",
    "What was the name of Barny Stinson's best friend in 'How I Met Your Mother'?\n(a) Matthew Perry\n(b) Marshall "
    "White\n(c) Ted Mosby\n(d) Rachel McDawes \n\n",
    "What is the antonym for perseverance? \n(a) Persistence \n(b) Spunk \n(c) Cowardice\n(d) Idleness\n\n"
]

questions = [
    Question(question_prompts[0], "c"),
    Question(question_prompts[1], "c"),
    Question(question_prompts[2], "c")
]


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)
コード例 #14
0
ファイル: MCQs.py プロジェクト: quamejnr/Python
from Questions import Question

question_prompts = [
    "What does Kwame love to sleep in? \n(a)Pyjamas \n(b)Birthday suit\n",
    "What is Kwame's favourite food? \n(a)Rice \n(b)Emo tuo\n"
]

questions = [
    Question(question_prompts[0], 'b'),
    Question(question_prompts[1], 'b'),
]


def test(questions):
    for question in questions:
        score = 0
        answer = input(question.prompt)
        if answer == question.answer:
            print("Correct\n")
            score += 1
        else:
            print("Wrong! the answer is " + question.answer + "\n")

    print('You got ' + str(score) + "/" + str(len(questions)) + " correct")


test(questions)
コード例 #15
0
from Questions import Question
q1 = "your favourite singer\n" + \
     "(a) MJ (b)z23"
a1 = 'a'
q2 = "your favourite game\n" + \
     "(a) csgo (b) dota2"
a2 = 'b'

question1 = Question(q1, a1)
question2 = Question(q2, a2)

questions = [question1, question2]

score = 0

for index in questions:
    print(index.prompt)
    youAnswer = input("enter your answer")
    if index.answer == youAnswer:
        print("your are right")
        score += 1
    else:
        print("wrong")

print("your score is:" + str(score) + "/" + "2")