Logaritmo

import math
from tkinter import *

root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#116f80")
root.title("Logaritmo ")

titulo = Label(text="Logaritmo ",
font=("Arial", "45", "bold"), bg="#116f80", fg="#8edfed")
titulo.place(relx=0.15, rely=0.05)

texto_sub1 = Label(text="Base do logaritmo:",
font=("Arial", "15", "bold"), bg="#116f80", fg="#8edfed")
texto_sub1.place(relx=0.15, rely=0.35)

texto_sub2 = Label(text="Número Natural:",
font=("Arial", "15", "bold"), bg="#116f80", fg="#8edfed")
texto_sub2.place(relx=0.19, rely=0.5)

Base_logaritmo = IntVar()
Base_logaritmo_entrada = Entry(textvariable=Base_logaritmo,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Base_logaritmo_entrada.place(relx=0.63, rely=0.35, relwidth=0.3)

Número_Natural = IntVar()
Número_Natural_entrada = Entry(textvariable=Número_Natural,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Número_Natural_entrada.place(relx=0.63, rely=0.5, relwidth=0.3)


def app():
n = Número_Natural.get()
l = Base_logaritmo.get()
result = math.log(n, l) # Calcula o logaritmo
resultado.set(f"O logaritmo de {n} na base {l} é {result:.4f}")


def limpar():
Número_Natural_entrada.delete(0, END)
Base_logaritmo_entrada.delete(0, END)
resultado.set("") # Inicializa a variável resultado


but1 = Button(text="Verificar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.05, 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.35, 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.65, rely=0.6, 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.75, relwidth=0.9, relheight=0.15)

root.mainloop()

Comentários

Mensagens populares deste blogue

Criar Cartões de Visita

12 signos egípcios

Calcular a percentagem de ocupação