Mensagens

A mostrar mensagens de fevereiro, 2025

Converter para leetspeak

from tkinter import * from tkinter.scrolledtext import ScrolledText root = Tk() root.geometry( "600x400" ) root.resizable( 0 , 0 ) root.config( bg = "#103030" ) root.title( "Converter para leetspeak" ) titulo = Label( text = "Converter para leetspeak" , font =( "Arial" , "28" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) titulo.place( relx = 0.15 , rely = 0.05 ) texto_sub1 = Label( text = "Frase :" , font =( "Arial" , "18" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub1.place( relx = 0.2 , rely = 0.32 ) Frase = StringVar() Frase_entrada = Entry( textvariable =Frase , font =( "Arial" , "12" , "bold" ) , bg = "white" , fg = "blue" , justify = 'center' ) Frase_entrada.place( relx = 0.38 , rely = 0...

Calcular o risco de seguro

from tkinter import * root = Tk() root.geometry( "600x600" ) root.resizable( 0 , 0 ) root.config( bg = "#103030" ) root.title( "Calcular o risco de seguro" ) titulo = Label( text = "Calcular o risco de seguro" , font =( "Arial" , "28" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) titulo.place( relx = 0.1 , rely = 0.05 ) texto_sub1 = Label( text = "Probabilidade incêndio(em %):" , font =( "Arial" , "18" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub1.place( relx = 0.05 , rely = 0.23 ) texto_sub2 = Label( text = "Custo médio de indenização:" , font =( "Arial" , "18" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub2.place( relx = 0.05 , rely = 0.35 ) texto_sub3 = Label( text = "Margem de Lucro (em %):"...

Adivinhar a letra

import random letras = "abcdefghijklmnopqrstuvwxyz" letra_secreta = random.choice(letras) tentativas = 0 escolha = True print ( "=" * 60 ) print ( " \t\t\t\t Adivinhar a letra" ) print ( "=" * 60 ) while escolha: print ( " \t\t\t 1 - Jogar \n\t\t\t 2 - Sair " ) opcao = input ( " \n Digite uma opção: " ) if opcao == "1" : while True : tentativa = input ( "Adivinhe a letra secreta (a-z): " ).lower() tentativas += 1 if tentativa == letra_secreta: print ( f"Parabéns! Você adivinhou a letra secreta em { tentativas } tentativas." ) break else : print ( "Tente novamente!" ) elif opcao == "2" : print ( "Fim do Programa." ) escolha = False else : print ( "Valor digitado inválido! Escolha novamente." )

Market Share

from tkinter import * # Create the main application window root = Tk() root.geometry( "500x400" ) root.resizable( 0 , 0 ) root.config( bg = "#103030" ) root.title( "Market Share" ) # Title label titulo = Label( text = "Market Share" , font =( "Arial" , "30" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) titulo.place( relx = 0.25 , rely = 0.05 ) # Sub-labels texto_sub1 = Label( text = "Vendas da Empresa:" , font =( "Arial" , "18" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub1.place( relx = 0.17 , rely = 0.25 ) texto_sub2 = Label( text = "Vendas Totais do Mercado:" , font =( "Arial" , "18" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub2.place( relx = 0.04 , rely = 0.45 ) # Input fields Vendas_Empresa = String...

Parque de Estacionamento (em Tkinter)

import time from tkinter import * class ParkingLot: def __init__ ( self , capacity , hourly_rate): self .capacity = capacity self .hourly_rate = hourly_rate self .current_vehicles = {} self .occupied_spots = 0 def enter_vehicle ( self , license_plate): if self .occupied_spots >= self .capacity: return "Estacionamento cheio!" if license_plate in self .current_vehicles: return f"Veículo { license_plate } já está estacionado." self .current_vehicles[license_plate] = time.time() self .occupied_spots += 1 return f"Veículo { license_plate } entrou no estacionamento." def exit_vehicle ( self , license_plate): if license_plate not in self .current_vehicles: return f"Veículo { license_plate } não encontrado." entry_time = self .current_vehicles.pop(license_plate) self .occupied_spots -= 1 total_time ...

Verificar Número Perfeito

from tkinter import * root = Tk() root.geometry( "600x300" ) root.resizable( 0 , 0 ) root.config( bg = "#103030" ) root.title( "Verificar Número Perfeito" ) titulo = Label( text = "Verificar número perfeito" , font =( "Arial" , "28" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) titulo.place( relx = 0.1 , rely = 0.05 ) texto_sub1 = Label( text = "Número para Verificar se é Perfeito" , font =( "Arial" , "18" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub1.place( relx = 0.15 , rely = 0.25 ) Número_Perfeito = StringVar() Número_Perfeito_entrada = Entry( textvariable =Número_Perfeito , font =( "Arial" , "12" , "bold" ) , bg = "white" , fg = "blue" , justify = 'center' ) Número_Perfeito_entrada.place...

Calcular Desconto

from tkinter import * root = Tk() root.geometry( "400x400" ) root.resizable( 0 , 0 ) root.config( bg = "#103030" ) root.title( "Calcular Desconto" ) titulo = Label( text = "Calcular Desconto" , font =( "Arial" , "28" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) titulo.place( relx = 0.08 , rely = 0.05 ) texto_sub1 = Label( text = "Preço de Venda:" , font =( "Arial" , "18" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub1.place( relx = 0.05 , rely = 0.25 ) texto_sub2 = Label( text = "Preço de Tabela:" , font =( "Arial" , "18" , "bold" ) , bg = "#103030" , fg = "#49e3e3" ) texto_sub2.place( relx = 0.05 , rely = 0.4 ) Preço_Venda = StringVar() Preço_tabela = StringVar() Preço_Venda_entrada = Entry( textvariable =Preço_Ven...

Capitais dos Países

from tkinter import * paises_capitais = { "Afeganistão" : "Cabul" , "África do Sul" : "Pretória" , "Albânia" : "Tirana" , "Alemanha" : "Berlim" , "Andorra" : "Andorra-a-Velha" , "Angola" : "Luanda" , "Antígua e Barbuda" : "Saint John's" , "Arábia Saudita" : "Riade" , "Argélia" : "Argel" , "Argentina" : "Buenos Aires" , "Arménia" : "Erevan" , "Austrália" : "Camberra" , "Áustria" : "Viena" , "Azerbaijão" : "Bacu" , "Bahamas" : "Nassau" , "Bahrein" : "Manama" , "Bangladeche" : "Daca" , "Barbados" : "Bridgetown" , "Bielorrússia" : "Minsk"...