-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFutoquiz.py
More file actions
111 lines (94 loc) · 3.36 KB
/
Futoquiz.py
File metadata and controls
111 lines (94 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import tkinter as tk
from tkinter import messagebox
# Lista de perguntas, opções e respostas
questions = [
{
"question": "Quem ganhou a Copa do Mundo de 2002?",
"options": ["Brasil", "Alemanha", "Argentina", "França"],
"answer": "Brasil",
},
{
"question": "Qual jogador é conhecido como 'Rei do Futebol'?",
"options": ["Maradona", "Pelé", "Zidane", "Cristiano Ronaldo"],
"answer": "Pelé",
},
{
"question": "Qual país sediou a Copa do Mundo de 2014?",
"options": ["Brasil", "África do Sul", "Rússia", "Alemanha"],
"answer": "Brasil",
},
{
"question": "Qual clube italiano é maior campeão da Copa da Itália?",
"options": ["Roma", "Juventus", "Milan", "Internazionale"],
"answer": "Juventus",
},
{
"question": "Qual jogador é conhecido como Imperador?",
"options": ["Kaka", "Totti", "Adriano", "Júlio Cesar"],
"answer": "Adriano",
},
{
"question": "Quem é maior artilheiro do seculo 21 do Campeonato Inglês?",
"options": ["Lampard", "Rooney", "Drogba", "Kane"],
"answer": "Kane",
},
]
current_question = 0
score = 0
def check_answer(selected_option, buttons):
global current_question, score
correct_answer = questions[current_question]["answer"]
# Desabilitar os botões após a seleção
for button in buttons:
button["state"] = "disabled"
# Verificar a resposta
if selected_option == correct_answer:
score += 1
buttons[questions[current_question]["options"].index(selected_option)]["bg"] = "green"
else:
buttons[questions[current_question]["options"].index(selected_option)]["bg"] = "red"
buttons[questions[current_question]["options"].index(correct_answer)]["bg"] = "green"
# Perguntar se deseja continuar
if messagebox.askyesno("Próxima pergunta", "Deseja continuar?"):
next_question()
else:
messagebox.showinfo("Fim do Quiz", f"Você acertou {score} de {len(questions)} perguntas.")
root.destroy()
def next_question():
global current_question
current_question += 1
if current_question < len(questions):
load_question()
else:
messagebox.showinfo("Fim do Quiz", f"Você acertou {score} de {len(questions)} perguntas.")
root.destroy()
def load_question():
for widget in frame.winfo_children():
widget.destroy()
question = questions[current_question]["question"]
options = questions[current_question]["options"]
question_label = tk.Label(
frame, text=question, font=("Arial", 16, "bold"), fg="yellow", bg="green"
)
question_label.pack(pady=20)
buttons = []
for option in options:
button = tk.Button(
frame,
text=option,
font=("Arial", 14),
bg="white",
fg="black",
command=lambda opt=option: check_answer(opt, buttons),
)
button.pack(pady=10, fill="x")
buttons.append(button)
# Configuração da janela principal
root = tk.Tk()
root.title("Quiz de Futebol")
root.geometry("600x400")
root.configure(bg="green")
frame = tk.Frame(root, bg="green")
frame.pack(expand=True, fill="both")
load_question()
root.mainloop()