Mundo em Python

Custo médio total

from tkinter import *
root = Tk()
root.geometry("650x400")
root.resizable(0, 0)
root.config(bg="#3f6a73")
root.title("Custo médio total (CMT)")
titulo = Label(text="Custo médio total (CMT)",
font=("Arial", "36", "bold"),bg="#3f6a73",fg="#16bbde")
titulo.place(relx=0.06, rely=0.05)
texto_sub1 = Label(text="Custo Total:",
font=("Arial", "18", "bold"),bg="#3f6a73",fg="#16bbde")
texto_sub1.place(relx=0.4, rely=0.25) texto_sub2 = Label(text="Número de Unidades Produzidas:",
font=("Arial", "18", "bold"),bg="#3f6a73",fg="#16bbde")
texto_sub2.place(relx=0.05, rely=0.4)
Custo_Total = DoubleVar()
Custo_Total_entrada = Entry(textvariable=Custo_Total,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Custo_Total_entrada.place(relx=0.67, rely=0.27, relwidth=0.25) Número_Produzidas = DoubleVar()
Número_Produzidas_entrada = Entry(textvariable=Número_Produzidas,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Número_Produzidas_entrada.place(relx=0.67, rely=0.41, relwidth=0.25) def app():
Q =Número_Produzidas.get()
ct = Custo_Total.get()
CMT = ct / Q
mensagem = f"Custo médio total (CMT): {round(CMT,2)} €"
resultado.set(mensagem) def limpar():
Número_Produzidas_entrada.delete(0, END)
Custo_Total_entrada.delete(0, END)
resultado.set("") but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.05, rely=0.6, relwidth=0.25, relheight=0.1)
but_limpar = Button(text="Limpar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=limpar)
but_limpar.place(relx=0.35, rely=0.6, relwidth=0.25, relheight=0.1) but_sair = Button(text="Sair", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=root.destroy)
but_sair.place(relx=0.65, rely=0.6, relwidth=0.25, relheight=0.1)
resultado = StringVar()
resultado_texto = Label(textvariable=resultado,
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.8, relwidth=0.9,relheight=0.15) root.mainloop()
0