Mundo em Python

Potência

#Fórmula da potência elétrica: potência = corrente * tensão
from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#d9ead3")
root.title("Potência")
def limpar():
Corrente_entrada.delete(0, END)
Tensão_entrada.delete(0, END) def app():
c = Corrente.get()
t = Tensão.get()
potência = c * t
resultado.set(potência) titulo = Label(text="Potência",
font=("Arial", "28", "bold"),bg="#d9ead3",fg="#bf9000")
titulo.place(relx=0.3, rely=0.05)
texto_sub1 = Label(text="Corrente Elétrica (em amperes) :",
font=("Arial", "12", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub1.place(relx=0.05, rely=0.25) texto_sub2 = Label(text="Tensão Elétrica (em volts ) :",
font=("Arial", "12", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub2.place(relx=0.14, rely=0.4)
Corrente = DoubleVar()
Corrente_entrada = Entry(textvariable=Corrente,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Corrente_entrada.place(relx=0.7, rely=0.25, relwidth=0.25) Tensão = DoubleVar()
Tensão_entrada = Entry(textvariable=Tensão,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Tensão_entrada.place(relx=0.7, rely=0.4, relwidth=0.25) but1 = Button(text="Verificar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.05, rely=0.55, 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.55, 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.55, 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.1)
root.mainloop()
0