Mundo em Python

Calcular o PI

from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#d9ead3")
root.title("Calcular o PI")
def limpar():
perímetro_entrada.delete(0, END)
diâmetro_entrada.delete(0, END) def app():
p = perímetro.get()
d = diâmetro.get()
pi = p/d
piarr = round(pi,3)
resultado.set(piarr) texto_sub1 = Label(text="Calcular o PI",
font=("Arial", "25", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub1.place(relx=0.25, rely=0.05) texto_sub2 = Label(text="Digite o diâmetro: ",
font=("Arial", "13", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub2.place(relx=0.15, rely=0.3) texto_sub3 = Label(text="Digite o perímetro: ",
font=("Arial", "13", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub3.place(relx=0.15, rely=0.45) perímetro = DoubleVar()
perímetro_entrada = Entry(textvariable=perímetro,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
perímetro_entrada.place(relx=0.55, rely=0.45, relwidth=0.3)
diâmetro = DoubleVar()
diâmetro_entrada = Entry(textvariable=diâmetro,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
diâmetro_entrada.place(relx=0.55, rely=0.3, relwidth=0.3)
but1 = Button(text="Calculadora", bd=2, bg='#107db2', fg='white',
font=('verdana', 10, 'bold'), command=app)
but1.place(relx=0.05, rely=0.65, relwidth=0.25, relheight=0.1)
but_limpar = Button(text="Limpar", bd=2, bg='#107db2', fg='white',
font=('verdana', 10, 'bold'), command=limpar)
but_limpar.place(relx=0.35, rely=0.65, relwidth=0.25, relheight=0.1)
but_sair = Button(text="Sair", bd=2, bg='#107db2', fg='white',
font=('verdana', 10, 'bold'), command=root.destroy)
but_sair.place(relx=0.65, rely=0.65, relwidth=0.25, relheight=0.1) texto_sub4 = Label(text="PI: ",
font=("Arial", "13", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub4.place(relx=0.35, rely=0.85)
resultado = StringVar()
resultado_texto = Label(textvariable=resultado,
font=("Arial", 12, "bold"),bg="#d9ead3")
resultado_texto.place(relx=0.45, rely=0.85, relwidth=0.35,relheight=0.08)
root.mainloop()
0