Mensagens

A mostrar mensagens de novembro, 2024

Calculadora Financeira (terminal)

import time import sys import os import matplotlib.pyplot as plt class CalculadoraFinanceira: def __init__ ( self ): self .historico = [] # Armazena os cálculos realizados @staticmethod def barra_progresso (total , atual , tamanho= 40 ): """Exibe uma barra de progresso""" percentagem = (atual / total) * 100 barra = '█' * int (percentagem / ( 100 / tamanho)) espacos = ' ' * (tamanho - len (barra)) sys.stdout.write( f" \r [ { barra }{ espacos } ] { percentagem : .2f } %" ) sys.stdout.flush() def calcular_roi ( self , investido_inicial , rentabilidade): try : roi = ((rentabilidade - investido_inicial) / investido_inicial) * 100 resultado = f"ROI: { roi : .2f } %" self .historico.append(( "ROI" , resultado)) return resultado except ZeroDivisionError : return "Erro...

Jogo de Copos

from tkinter import * import random root = Tk() root.geometry( "400x400" ) root.resizable( 0 , 0 ) root.config( bg = "#103030" ) root.title( "Jogo de Copos" ) titulo = Label( text = "Jogo de Copos" , font =( "Arial" , "28" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) titulo.place( relx = 0.15 , rely = 0.05 ) texto_sub1 = Label( text = "Escolha :" , font =( "Arial" , "18" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub1.place( relx = 0.15 , rely = 0.3 ) escolha = StringVar() escolha_entrada = Entry( textvariable =escolha , font =( "Arial" , "12" , "bold" ) , bg = "white" , fg = "blue" , justify = 'center' ) escolha_entrada.place( relx = 0.55 , rely = 0.31 , relwidth = 0.35 ) escolha_entrada....

Litro para Galão (usando tkinter)

import tkinter as tk from functools import partial # Variável global tempVal = "Galão Americano" def armazenar_temp (sel_temp): global tempVal tempVal = sel_temp def chamar_converter (rlabel1 , inputn): tem = inputn.get() try : tem = float (tem) if tempVal == 'Galão Americano' : gi1 = float (tem * 0.832674 ) l1 = float (tem * 3.78541 ) mensagem = f"Galão Imperial: { round (gi1 , 2 ) }\n Litros: { round (l1 , 2 ) } " rlabel1.config( text =mensagem) elif tempVal == 'Galão Imperial' : l2 = float (tem * 4.54609 ) ga2 = float (tem / 0.832674 ) mensagem = f"Galão Americano: { round (ga2 , 2 ) }\n Litros: { round (l2 , 2 ) } " rlabel1.config( text =mensagem) elif tempVal == 'Litro' : galao_americano = float (tem / 3.78541 ) galao_imperial = float (tem / 4.54609 ) ...

Consumir Álcool

from tkinter import * from datetime import datetime root = Tk() root.geometry( "400x400" ) root.resizable( 0 , 0 ) root.config( bg = "#103030" ) root.title( "Consumir Álcool " ) titulo = Label( text = "Verificar se pode beber álcool " , font =( "Arial" , "19" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) titulo.place( relx = 0.05 , rely = 0.05 ) sub1 = Label( text = "Data de Nascimento (YYYY-MM-DD) " , font =( "Arial" , "15" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) sub1.place( relx = 0.05 , rely = 0.25 ) Data_Nascimento = StringVar() Data_Nascimento_entrada = Entry( textvariable =Data_Nascimento , font =( "Arial" , "12" , "bold" ) , bg = "white" , fg = "blue" , justify = 'center' ) Data_Nascimento_entrada.place( relx = 0.35 , rely = 0....

Advento Natal

from tkinter import * from datetime import datetime # Função para atualizar o texto com o conteúdo de cada dia def mostrar_dia (dia): conteudos = { 1 : "Dia 1: Pequeno chocolate e um versículo sobre a esperança." , 2 : "Dia 2: Decoração de árvore de Natal." , 3 : "Dia 3: Um brinquedinho pequeno." , 4 : "Dia 4: Fazer biscoitos natalinos." , 5 : "Dia 5: Um versículo sobre a paz e um ornamento para a árvore." , 6 : "Dia 6: Um saquinho de doces." , 7 : "Dia 7: Assistir a um filme de Natal em família." , 8 : "Dia 8: Um enfeite de Natal para colorir." , 9 : "Dia 9: Fazer um cartão de Natal." , 10 : "Dia 10: Um versículo sobre a alegria e uma pequena vela." , 11 : "Dia 11: Um saquinho de chá especial." , 12 : "Dia 12: Caminhada noturna para ver as luzes de Natal." , 13...

Detector de Palíndromo (usando Tkinter)

from tkinter import * root = Tk() root.geometry( "400x400" ) root.resizable( 0 , 0 ) root.config( bg = "#d9ead3" ) root.title( "Detector de Palíndromo" ) def limpar (): frase_entrada.delete( 0 , END) def app (): f = frase.get() fp = f.strip().split() junto = '' .join(fp).upper() inverso = junto[::- 1 ] if inverso == junto: teste = 'A frase digitada é um palindromo' else : teste = 'A frase não e um palindromo' mensagem = f'A frase { junto }\n Ivertida e { inverso }\n{ teste } ' resultado.set(mensagem) titulo = Label( text = "Detector de Palíndromo" , font =( "Arial" , "15" , "bold" ) , bg = "#d9ead3" , fg = "#bf9000" ) titulo.place( relx = 0.25 , rely = 0.05 ) texto_sub1 = Label( text = "Frase:" , font =( "Arial" , "12" , "bold" ) , bg = ...

Nível de álcool no Brasil (usando Tkinter)

from tkinter import * root = Tk() root.geometry( "700x400" ) root.resizable( 0 , 0 ) root.config( bg = "#103030" ) root.title( "Nível de álcool no Brasil" ) titulo = Label( text = "Nível de álcool no Brasil" , font =( "Arial" , 28 , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) titulo.place( relx = 0.15 , rely = 0.05 ) texto_sub1 = Label( text = "Nível de álcool no bafômetro (mg/L de ar expelido)" , font =( "Arial" , 18 , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub1.place( relx = 0.05 , rely = 0.3 ) Nível_álcool = StringVar() Nível_álcool_entrada = Entry( textvariable =Nível_álcool , font =( "Arial" , 12 , "bold" ) , bg = "white" , fg = "blue" , justify = 'center' ) Nível_álcool_entrada.place( relx = 0.05 , rel...

Calcular Multiplicação (usando tkinter )

from tkinter import * root = Tk() root.geometry( "500x300" ) root.resizable( 0 , 0 ) root.config( bg = "#103030" ) root.title( "Calcular Multiplicação" ) titulo = Label( text = "Calcular Multiplicação" , font =( "Arial" , "25" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) titulo.place( relx = 0.15 , rely = 0.05 ) texto_sub1 = Label( text = "Número 1" , font =( "Arial" , "18" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub1.place( relx = 0.18 , rely = 0.25 ) texto_sub2 = Label( text = "Número 2" , font =( "Arial" , "18" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub2.place( relx = 0.62 , rely = 0.25 ) texto_sub3 = Label( text = "X" , font =( "Arial" , "18" , ...