def main(): q1 = questions.question( "What year did the Beatles make it big in america? ", "A. 1965", "B. 1945", "C, 1956", "D, 1964") q2 = questions.question( "Which famous musician from the Beatles was murdered in 1980? ", "A. Ringo Starr", "B. John Lennon", "C. George Harrison", "D. Geezer Butler") q3 = questions.question("How many sides does a hexagon have?" "A. 4", "B. 6", "C. 9", "D. 7") q4 = questions.question( "Who wrote the Harry Potter series?" "A. J.K. Rowling", "B. Stephen King", "C. George R. R. Martin", "D. Thomas Kinkaid") all_questions = (q1, q2, q3, q4) print("* Player 1 *") player1 = ask(all_questions) print("* Player 1 *") player2 = ask(all_questions) if player1 == player2: print("You two are now tied!") elif player1 > player2: print("Player 1 is winner of this quiz!") else: print("Player 2 is the winner of this quiz!")
def update_ques(user_ask, coin): try: icoin = int(coin) list_questions = getQuestions() q = question(list_questions, user_ask) cur_coin = q.coin - icoin sql = "UPDATE users SET coin = {} WHERE user_ask={}".format( cur_coin, user_ask) conn = mysql.connect() cursor = conn.cursor() cursor.execute(sql) conn.commit() res = jsonify('User updated successfully.') res.status_code = 200 return res except Exception as e: print(e) finally: cursor.close() conn.close()
from Tkinter import * import akinator import questions import shutil import ttk from ttk import Button,Style q =questions.question() listeReponse={} def Ok(): Texte.set("Super !") quit() def update(cap,discriminant,question): for i in q.questionPasse: if i[1] == 3 or i[1] == 1: listeReponse[i[0]["attrib"]] = "True" else: listeReponse[i[0]["attrib"]] = "False" q.instanceMoteur.db.addCapitale(cap.get(), listeReponse) shutil.copy2("out.csv", "villesTF.csv") q.instanceMoteur.db.addDiscriminant(discriminant.get(),cap.get(),question.get()) shutil.copy2("out.csv", "villesTF.csv") shutil.copy2("out1.csv", "question.csv") quit() def Ko(): non = Toplevel()
def chatroom(username): list_questions = getQuestions() q = question(list_questions, username) return render_template('chatroom.html', template_q = q)
from questions import question question_prompts = [ "what color are apples?\n(a) red/green\n(b) purple\n(c) blue\n\n", "what color are bananas?\n(a) blue\n(b) black\n(c) yellow\n\n", "what color are strawberries?\n(a) red\n(b) green\n(c) brown\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: scrore += 1 print("You got " + str(score) + "/" + str(len(questions)) + " correct") run_test(questions)
from Tkinter import * import akinator import questions import shutil import ttk from ttk import Button, Style q = questions.question() listeReponse = {} def Ok(): Texte.set("Super !") quit() def update(cap, discriminant, question): for i in q.questionPasse: if i[1] == 3 or i[1] == 1: listeReponse[i[0]["attrib"]] = "True" else: listeReponse[i[0]["attrib"]] = "False" q.instanceMoteur.db.addCapitale(cap.get(), listeReponse) shutil.copy2("out.csv", "villesTF.csv") q.instanceMoteur.db.addDiscriminant(discriminant.get(), cap.get(), question.get()) shutil.copy2("out.csv", "villesTF.csv") shutil.copy2("out1.csv", "question.csv") quit()
def main(): global score end = False correct = "" curr_ques = 1 pygame.init() clock = pygame.time.Clock() screen = pygame.display.set_mode([SCREEN_WIDTH, SCREEN_HEIGHT]) pygame.display.set_caption("Image Quiz!") ques = question(curr_ques) answer = pygame_textinput.TextInput() score_txt = show_txt("Score: " + str(score)) hint = "" running = True img, txt = ques.gen_ques() sub_button = pygame.Rect(QUES_WIDTH, QUES_HEIGHT + 100, 150, 50) hint_btn = pygame.Rect(QUES_WIDTH, QUES_HEIGHT + 350, 150, 50) while running: smallText = pygame.font.Font("freesansbold.ttf", 20) events = pygame.event.get() for event in events: if event.type == pygame.QUIT: running = False if event.type == pygame.MOUSEBUTTONDOWN: mouse_pos = event.pos if sub_button.collidepoint(mouse_pos): usr_answer = (answer.get_text()).lower() if ans[curr_ques - 1] == usr_answer: curr_ques += 1 if curr_ques <= 10: hint = "" print("Correct") correct = "Correct!" score += 1 score_txt = ("Score: " + str(score)) textSurf2, textRect2 = text_objects( correct, smallText, screen, (0, 200, 0)) textRect2.center = (QUES_WIDTH + 40, QUES_HEIGHT + 300) screen.blit(textSurf2, textRect2) ques = question(curr_ques) img, txt = ques.gen_ques() else: hint = "" print("Correct") correct = "Correct!" score += 1 score_txt = ("Score: " + str(score)) textSurf2, textRect2 = text_objects( correct, smallText, screen, (0, 200, 0)) textRect2.center = (QUES_WIDTH + 40, QUES_HEIGHT + 300) screen.blit(textSurf2, textRect2) end = True break # running = False else: if curr_ques <= 10: hint = "" print("Wrong") correct = "Wrong!" time.sleep(0.5) curr_ques += 1 ques = question(curr_ques) img, txt = ques.gen_ques() else: hint = "" print("Wrong") correct = "Wrong!" score += 1 score_txt = ("Score: " + str(score)) textSurf2, textRect2 = text_objects( correct, smallText, screen, (200, 0, 0)) textRect2.center = (QUES_WIDTH + 40, QUES_HEIGHT + 300) screen.blit(textSurf2, textRect2) end = True break if hint_btn.collidepoint(mouse_pos): hint = hints[curr_ques - 1] print(hint) screen.fill(COLOR_WHITE) screen.blit(img, (0, 0)) screen.blit(txt, (QUES_WIDTH, QUES_HEIGHT)) pygame.draw.rect(screen, (0, 100, 0), sub_button) pygame.draw.rect(screen, (0, 0, 200), hint_btn) if answer.update(events): print(answer.get_text()) usr_answer = (answer.get_text()).lower() # time.sleep(40) # running = False if ans[curr_ques - 1] == usr_answer: curr_ques += 1 hint = "" if curr_ques <= 10: print("Correct") correct = "Correct!" score += 1 score_txt = ("Score: " + str(score)) textSurf2, textRect2 = text_objects( correct, smallText, screen, (0, 200, 0)) textRect2.center = (QUES_WIDTH + 40, QUES_HEIGHT + 300) screen.blit(textSurf2, textRect2) ques = question(curr_ques) img, txt = ques.gen_ques() else: print("Correct") correct = "Correct!" score += 1 score_txt = ("Score: " + str(score)) textSurf2, textRect2 = text_objects( correct, smallText, screen, (0, 200, 0)) textRect2.center = (QUES_WIDTH + 40, QUES_HEIGHT + 300) screen.blit(textSurf2, textRect2) end = True else: curr_ques += 1 hint = "" if curr_ques <= 10: print("Wrong") correct = "Wrong!" time.sleep(0.5) ques = question(curr_ques) img, txt = ques.gen_ques() else: print("Wrong") correct = "Wrong!" score += 1 score_txt = ("Score: " + str(score)) textSurf2, textRect2 = text_objects( correct, smallText, screen, (200, 0, 0)) textRect2.center = (QUES_WIDTH + 40, QUES_HEIGHT + 300) screen.blit(textSurf2, textRect2) end = True screen.blit(answer.get_surface(), (QUES_WIDTH, QUES_HEIGHT + 50)) textSurf, textRect = text_objects("Check", smallText, screen, COLOR_WHITE) textRect.center = (QUES_WIDTH + 70, QUES_HEIGHT + 125) screen.blit(textSurf, textRect) textSurf3, textRect3 = text_objects(hint, smallText, screen, (200, 200, 200)) textRect3.center = (SCREEN_WIDTH // 2, (SCREEN_HEIGHT // 2) + 200) screen.blit(textSurf3, textRect3) textSurf, textRect = text_objects("Hint?", smallText, screen, COLOR_WHITE) textRect.center = (QUES_WIDTH + 70, QUES_HEIGHT + 375) screen.blit(textSurf, textRect) textSurf2, textRect2 = text_objects(("Score: " + str(score)), smallText, screen, COLOR_BLACK) textRect2.center = (QUES_WIDTH + 40, QUES_HEIGHT + 200) screen.blit(textSurf2, textRect2) if (end): time.sleep(1) running = False if (correct == "Correct!"): textSurf2, textRect2 = text_objects(correct, smallText, screen, (0, 200, 0)) textRect2.center = (QUES_WIDTH + 40, QUES_HEIGHT + 300) screen.blit(textSurf2, textRect2) elif (correct == "Wrong!"): textSurf2, textRect2 = text_objects(correct, smallText, screen, (200, 0, 0)) textRect2.center = (QUES_WIDTH + 40, QUES_HEIGHT + 300) screen.blit(textSurf2, textRect2) else: textSurf2, textRect2 = text_objects(correct, smallText, screen, COLOR_BLACK) textRect2.center = (QUES_WIDTH + 40, QUES_HEIGHT + 300) screen.blit(textSurf2, textRect2) pygame.display.update() clock.tick(30) pygame.quit()
import csv from questions import question filePath = "survey.csv" #survey class class survey: def __init__(self): self.questions = [] self.regions = [ 'Abruzzo', 'Basilicata', 'Calabria', 'Campania', 'Emilia-Romagna', 'Friuli-Venezia Giulia', 'Lazio', 'Liguria', 'Lombardy', 'Marches', 'Molise', 'Piedmont', 'Apulia', 'Sardinia', 'Sicily', 'Tuscany', 'Trentino-South Tyrol', 'Umbria', 'Aosta Valley', 'Veneto' ] #self.LoadQuesAns() #def Load(self): #def GiveSurvey x = survey() for region in x.regions: print(region) q = question() print(q.prompt)