Mundo em Python

5 perguntas para uma pessoa sobre um crime

from tkinter import *

def selecionar():
global resposta1, resposta2, resposta3, resposta4, resposta5 # Contagem de respostas positivas
positivos = resposta1.get() + resposta2.get() + resposta3.get() + resposta4.get() + resposta5.get() # Lógica de classificação
if positivos < 2:
mensagem="Inocente"
elif positivos == 2:
mensagem="Suspeita"
elif positivos < 5:
mensagem="Cúmplice"
else:
mensagem="Assassino"
resultado.set(mensagem) root = Tk()
root.geometry("500x500")
root.resizable(0, 0)
root.title("5 perguntas para uma pessoa sobre um crime")
root.config(bg="#103030") titulo = Label(text="5 perguntas para uma pessoa sobre um crime",
font=("Arial", "16", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.05, rely=0.05) texto_sub1 = Label(text="Telefonou para a vítima? ",
font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.05, rely=0.2) # Radiobuttons para a primeira pergunta
resposta1 = IntVar()
Radiobutton(root, text="Sim", variable=resposta1, value=1, command=selecionar,
font=("Arial", "12"), bg="#103030", fg="black").place(relx=0.6, rely=0.2)
Radiobutton(root, text="Não", variable=resposta1, value=0, command=selecionar,
font=("Arial", "12"), bg="#103030", fg="black").place(relx=0.75, rely=0.2) texto_sub2 = Label(text="Esteve no local do crime? ",
font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
texto_sub2.place(relx=0.05, rely=0.3) # Radiobuttons para a segunda pergunta
resposta2 = IntVar()
Radiobutton(root, text="Sim", variable=resposta2, value=1, command=selecionar,
font=("Arial", "12"), bg="#103030", fg="black").place(relx=0.6, rely=0.3)
Radiobutton(root, text="Não", variable=resposta2, value=0, command=selecionar,
font=("Arial", "12"), bg="#103030", fg="black").place(relx=0.75, rely=0.3) texto_sub3 = Label(text="Mora perto da vítima?",
font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
texto_sub3.place(relx=0.05, rely=0.4) # Radiobuttons para a terceira pergunta
resposta3 = IntVar()
Radiobutton(root, text="Sim", variable=resposta3, value=1, command=selecionar,
font=("Arial", "12"), bg="#103030", fg="black").place(relx=0.6, rely=0.4)
Radiobutton(root, text="Não", variable=resposta3, value=0, command=selecionar,
font=("Arial", "12"), bg="#103030", fg="black").place(relx=0.75, rely=0.4) texto_sub4 = Label(text="Devia para a vítima?",
font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
texto_sub4.place(relx=0.05, rely=0.5) # Radiobuttons para a quarta pergunta
resposta4 = IntVar()
Radiobutton(root, text="Sim", variable=resposta4, value=1, command=selecionar,
font=("Arial", "12"), bg="#103030", fg="black").place(relx=0.6, rely=0.5)
Radiobutton(root, text="Não", variable=resposta4, value=0, command=selecionar,
font=("Arial", "12"), bg="#103030", fg="black").place(relx=0.75, rely=0.5) texto_sub5 = Label(text="Já trabalhou com a vítima??",
font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
texto_sub5.place(relx=0.05, rely=0.6) # Radiobuttons para a quinta pergunta
resposta5 = IntVar()
Radiobutton(root, text="Sim", variable=resposta5, value=1, command=selecionar,
font=("Arial", "12"), bg="#103030", fg="black").place(relx=0.6, rely=0.6)
Radiobutton(root, text="Não", variable=resposta5, value=0, command=selecionar,
font=("Arial", "12"), bg="#103030", fg="black").place(relx=0.75, rely=0.6)
resultado = StringVar()
resultado_texto = Label(textvariable=resultado,
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.75, relwidth=0.9, relheight=0.18) root.mainloop()
0