Mundo em Python

lambda

from tkinter import *
root = Tk()
root.geometry("300x300")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("lambda")
quadrado = lambda vx, vy: vx ** 2 + vy
sub1 = Label(text="Número X:",
font=("Arial", "12", "bold"), bg="#103030", fg="#49e3e3")
sub1.place(relx=0.1, rely=0.05) x = StringVar()
x_entrada = Entry(textvariable=x,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
x_entrada.place(relx=0.5, rely=0.05, relwidth=0.45)
x_entrada.focus() sub2 = Label(text="Número Y:",
font=("Arial", "12", "bold"), bg="#103030", fg="#49e3e3")
sub2.place(relx=0.1, rely=0.2) y = StringVar()
y_entrada = Entry(textvariable=y,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
y_entrada.place(relx=0.5, rely=0.2, relwidth=0.45)
y_entrada.focus() def limpar():
y_entrada.delete(0, END)
x_entrada.delete(0, END)
resultado_texto.config(text="") def app():
try:
vxx = int(x.get())
vyy = int(y.get())
resultado = quadrado(vxx, vyy)
resultado_texto.config(text=f"O Resultado é: {resultado}") except ValueError:
resultado_texto.config(text="Erro! Insira números válidos.") but1 = Button(text="Mostrar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, rely=0.48, 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.4, rely=0.48, 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.7, rely=0.48, relwidth=0.25, relheight=0.1) resultado_texto = Label(font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.68, relwidth=0.9, relheight=0.3)
root.mainloop()
0