Mundo em Python

Cateto desconhecido

import math
from tkinter import * root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Cateto desconhecido") titulo = Label(text="Cateto desconhecido",
font=("Arial", "25", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.1, rely=0.05) sub1 = Label(text="Hipotenusa: ", font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
sub1.place(relx=0.25, rely=0.25) sub2 = Label(text="Cateto Conhecido: ", font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
sub2.place(relx=0.05, rely=0.45) Hipotenusa = StringVar()
Hipotenusa_entrada = Entry(textvariable=Hipotenusa,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Hipotenusa_entrada.place(relx=0.65, rely=0.27, relwidth=0.3)
Hipotenusa_entrada.focus() Cateto = StringVar()
Cateto_entrada = Entry(textvariable=Cateto,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Cateto_entrada.place(relx=0.65, rely=0.45, relwidth=0.3) def limpar():
Cateto_entrada.delete(0, END)
Hipotenusa_entrada.delete(0, END)
resultado_texto.config(text="") def calcular_cateto():
try:
c1 = float(Cateto.get())
h = float(Hipotenusa.get())
cateto_desconhecido = math.sqrt(h ** 2 - c1 ** 2)
resultado_texto.config(text=f"Cateto desconhecido: {round(cateto_desconhecido,2)}")
except ValueError:
resultado_texto.config(text="Entrada incorreta!!") but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=calcular_cateto)
but1.place(relx=0.1, 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.4, 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.7, rely=0.6, relwidth=0.25, relheight=0.1) resultado_texto = Label(font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.75, relwidth=0.9, relheight=0.15) root.mainloop()
0