Mundo em Python

Valor final do Investimento

from tkinter import *
root = Tk()
root.geometry("400x350")
root.resizable(0, 0)
root.config(bg="#d9ead3")
def limpar():
valor_inicial_entrada.delete(0, END)
taxa_juros_entrada.delete(0, END)
anos_entrada.delete(0, END)
def app():
val_inicial=valor_inicial.get()
tx_juros = taxa_juros.get()
tx_jurosp = tx_juros/100
prazo = anos.get()
valor_final = val_inicial * (1 + tx_jurosp) ** prazo
valor_finalpp = round(valor_final,2)
resultado.set(valor_finalpp)
root.title("Valor final do Investimento")
titulo = Label(text="Valor final do Investimento",
font=("Arial", "15", "bold"),bg="#d9ead3",fg="#bf9000")
titulo.place(relx=0.2, rely=0.05) texto_sub1 = Label(text="Valor Inicial:",
font=("Arial", "13", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub1.place(relx=0.2, rely=0.25) texto_sub2 = Label(text="Taxa de Juro(%):",
font=("Arial", "13", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub2.place(relx=0.1, rely=0.35) texto_sub3 = Label(text="Anos:",
font=("Arial", "13", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub3.place(relx=0.3, rely=0.45)
valor_inicial = DoubleVar()
valor_inicial_entrada = Entry(textvariable=valor_inicial,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
valor_inicial_entrada.place(relx=0.5, rely=0.25, relwidth=0.3) taxa_juros = DoubleVar()
taxa_juros_entrada = Entry(textvariable=taxa_juros,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
taxa_juros_entrada.place(relx=0.5, rely=0.35, relwidth=0.3) anos = IntVar()
anos_entrada = Entry(textvariable=anos,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
anos_entrada.place(relx=0.5, rely=0.45, relwidth=0.3)
but1 = Button(text="Verificar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'),command=app)
but1.place(relx=0.25, 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.55, rely=0.55, relwidth=0.25, relheight=0.1) texto = Label(text="Final do Investimento: ",
font=("Arial", 12, "bold"), bg="#cfe2f3",fg="#a83250")
texto.place(relx=0.1, rely=0.75)
resultado = StringVar()
resultado_texto = Label(textvariable=resultado,
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.55, rely=0.75, relwidth=0.25,relheight=0.1)
root.mainloop()
0