Mensagens

A mostrar mensagens de outubro, 2023

Valor do CDS

from tkinter import * root = Tk() root.geometry( "400x400" ) root.resizable( 0 , 0 ) root.config( bg = "#1a5a96" ) root.title( "Valor do CDS" ) titulo = Label( text = "Valor do CDS" , font =( "Arial" , "42" , "bold" ) , bg = "#1a5a96" , fg = "#12dbc7" ) titulo.place( relx = 0.05 , rely = 0.05 ) texto_sub1 = Label( text = "Prémio Periódico:" , font =( "Arial" , "15" , "bold" ) , bg = "#1a5a96" , fg = "#12dbc7" ) texto_sub1.place( relx = 0.1 , rely = 0.35 ) texto_sub2 = Label( text = "Recuperação:" , font =( "Arial" , "12" , "bold" ) , bg = "#1a5a96" , fg = "#12dbc7" ) texto_sub2.place( relx = 0.15 , rely = 0.55 ) prémio_periodico = DoubleVar() prémio_periodico_entrada = Entry( textvariable =prémio_periodico , ...

Gerador de Jack-o'-Lantern

import tkinter as tk def criar_abobora (): tamanho = tamanho_slider.get() olhos = olhos_var.get() boca = boca_var.get() abobora.create_rectangle( 50 , 50 , 250 , 250 , fill = 'orange' ) abobora.create_oval( 100 , 100 , 140 , 140 , fill = 'white' ) abobora.create_oval( 160 , 100 , 200 , 140 , fill = 'white' ) if olhos == "Triangulares" : abobora.create_polygon( 120 , 120 , 130 , 100 , 140 , 120 , fill = 'black' ) abobora.create_polygon( 180 , 120 , 190 , 100 , 200 , 120 , fill = 'black' ) else : abobora.create_oval( 125 , 130 , 135 , 140 , fill = 'black' ) abobora.create_oval( 185 , 130 , 195 , 140 , fill = 'black' ) if boca == "Feliz" : abobora.create_arc( 125 , 170 , 195 , 200 , start = 0 , extent = 180 , style =tk.CHORD) else : abobora.create_arc( 125 , 170 , 195 , 200 , start = 0 , extent =- 180 , style =tk.CHORD) # Confi...

Velocidade na Autoestrada

print ( "Velocidade na Autoestrada" ) velocidade_atual = float ( input ( "Digite a sua velocidade: " )) if velocidade_atual >= 50 and velocidade_atual <= 120 : print ( "Velocidade está dentro do limite legal." ) elif velocidade_atual < 50 : print ( "Abaixo do limite legal." ) else : print ( "Acima do limite legal." )

Converter a Velocidade do Vento

import time escolha= True while escolha: print ( " \n " ) print ( "Converter a Velocidade do Vento" ) print ( """ 1. Metros por Segundo (m/s) 2. Quilômetros por Hora (km/h) 3. Nós (kt) 4. Milhas por Hora (mph) 8.Exit/Quit/Saída """ ) escolha= input ( "Escolha uma opção: " ) if escolha== "1" : print ( " \t\t Converter a Velocidade do Vento \n " ) velocidade_mps = float ( input ( "Digite a Velocidade do vento por Metros por Segundo (m/s):" )) print ( "Converter Metros por Segundo (m/s): \n " ) velocidade_kph=velocidade_mps * 3.6 print ( f"Quilômetros por Hora (km/h): { velocidade_mps } m/s é igual a { round (velocidade_kph , 2 ) } km/h." ) velocidade_kt =velocidade_mps / 1.852 print ( f"Nós (kt): { velocidade_mps } m/s é igual a { round (velocidade_kt , 2 ) } kt. " ...

Lanterna

from tkinter import * import random def tremeluzir (): cor = random.choice([ "#ffcc00" , "#ff9900" , "#ff6600" , "#ff3300" , "#ff0000" ]) vela.config( bg =cor) root.after( 200 , tremeluzir) root = Tk() root.title( "Lanterna" ) root.geometry( "300x300" ) root.resizable( 0 , 0 ) root.configure( bg = "black" ) vela = Label( bg = "#ffcc00" , width = 30 , height = 10 ) vela.pack( pady = 50 ) tremeluzir() root.mainloop()

Verificador de Força de Senha

from tkinter import * root = Tk() root.geometry( "400x300" ) root.resizable( 0 , 0 ) root.config( bg = "#054c69" ) root.title( "Verificador de Força de Senha" ) titulo = Label( text = "Verificador de Força de Senha" , font =( "Arial" , "19" , "bold" ) , bg = "#054c69" , fg = "#0edeed" ) titulo.place( relx = 0.05 , rely = 0.05 ) texto_sub1 = Label( text = "Senha:" , font =( "Arial" , "15" , "bold" ) , bg = "#054c69" , fg = "#0edeed" ) texto_sub1.place( relx = 0.15 , rely = 0.35 ) Senha = StringVar() Senha_entrada = Entry( textvariable =Senha , font =( "Arial" , "12" , "bold" ) , bg = "white" , fg = "blue" , justify = 'center' ) Senha_entrada.place( relx = 0.35 , rely = 0.35 , relwidth = 0.6...

Gerar Nomes Assustadores

import time import random escolha= True while escolha: print ( " \n " ) print ( " Gerar Nomes Assustadores" ) print ( """ 1. Gerar Nomes Assustadores 0. Exit/Quit/Saída """ ) escolha= input ( "Escolha uma opção: " ) if escolha== "1" : palavras_assustadoras = [ "fantasma" , "zumbi" , "bruxa" , "vampiro" , "lobisomem" , "esqueleto" , "monstro" , "demônio" ] adjetivos_assustadores = [ "assustador" , "aterrorizante" , "sinistro" , "horripilante" , "macabro" , "medonho" , "sombrio" ] numero_nomes = int ( input ( "Digite o número de nomes assustadores: " )) for _ in r...

Rácio Dívida Pública (usando tkinter)

from tkinter import * root = Tk() root.geometry( "400x400" ) root.resizable( 0 , 0 ) root.config( bg = "#d9ead3" ) root.title( "Rácio Dívida Pública" ) titulo = Label( text = "Rácio Dívida Pública" , font =( "Arial" , "28" , "bold" ) , bg = "#d9ead3" , fg = "#bf9000" ) titulo.place( relx = 0.05 , rely = 0.05 ) texto_sub1 = Label( text = "Dívida Pública Total:" , font =( "Arial" , "12" , "bold" ) , bg = "#d9ead3" , fg = "#bf9000" ) texto_sub1.place( relx = 0.13 , rely = 0.3 ) texto_sub2 = Label( text = "Produto Interno Bruto:" , font =( "Arial" , "12" , "bold" ) , bg = "#d9ead3" , fg = "#bf9000" ) texto_sub2.place( relx = 0.1 , rely = 0.45 ) Dívida_Pública_Total = DoubleVar() Dívida_Pública_Total_entrada = Entry( textvariable ...

Transformar tudo em Maiúsculas ou Transformar tudo em Minúsculas

import time escolha= True while escolha: print ( " \n " ) print ( " Maiúsculas e Miúsculas" ) print ( """ 1. Transformar tudo em Maiúsculas 2. Transformar tudo em Minúsculas 0. Exit/Quit/Saída """ ) escolha= input ( "Escolha uma opção: " ) if escolha== "1" : frase1 = input ( "Transformar tudo em Maiúsculas: " ).upper() print ( f"Frase toda em Maiúsculas: { frase1 } " ) time.sleep( 2 ) elif escolha== "2" : frase2 = input ( "Transformar tudo em Minúsculas: " ).lower() print ( f"Frase toda em Minúsculas: { frase2 } " ) time.sleep( 2 ) elif escolha== "8" : print ( " \n Adeus" ) escolha = None else : print ( " \n Escolha não válida. \n Tente outra vez." )

Simulador de Imposto de Rendimento

from tkinter import * root = Tk() root.geometry( "400x300" ) root.resizable( 0 , 0 ) root.config( bg = "#111e80" ) root.title( "Simulador de Imposto de Rendimento" ) titulo = Label( text = "Imposto de Rendimento" , font =( "Arial" , "15" , "bold" ) , bg = "#111e80" , fg = "#1fedd2" ) titulo.place( relx = 0.25 , rely = 0.05 ) texto_sub1 = Label( text = "Rendimento anual: " , font =( "Arial" , "15" , "bold" ) , bg = "#111e80" , fg = "#1fedd2" ) texto_sub1.place( relx = 0.05 , rely = 0.35 ) Rendimento_anual = DoubleVar() Rendimento_anual_entrada = Entry( textvariable =Rendimento_anual , font =( "Arial" , "12" , "bold" ) , bg = "white" , fg = "blue" , justify = 'center' ) Rendimento_anual_entr...

Cor RGB

from tkinter import * root = Tk() root.geometry( "400x400" ) root.resizable( 0 , 0 ) root.config( bg = "#d9ead3" ) root.title( "Cor RGB" ) titulo = Label( text = "Cor RGB" , font =( "Arial" , "35" , "bold" ) , bg = "#d9ead3" , fg = "#bf9000" ) titulo.place( relx = 0.25 , rely = 0.05 ) texto_sub1 = Label( text = "Vermelho" , font =( "Arial" , "15" , "bold" ) , bg = "#d9ead3" , fg = "#bf9000" ) texto_sub1.place( relx = 0.1 , rely = 0.3 ) texto_sub2 = Label( text = "Verde" , font =( "Arial" , "15" , "bold" ) , bg = "#d9ead3" , fg = "#bf9000" ) texto_sub2.place( relx = 0.45 , rely = 0.3 ) texto_sub3 = Label( text = "Azul" , font =( "Arial" , "15" , "bold" ) , bg = "#d9ead3" , fg = "#bf9000" ) texto_sub3.place( relx = 0.75 , ...

Calcular a alcoolémia ao longo do tempo

from tkinter import * from functools import partial root = Tk() root.title( 'Calcular a alcoolémia ao longo do tempo' ) root.geometry( "400x450" ) root.configure( background = '#09A3BA' ) root.resizable( False, False ) tempVal = "Homem" def store_temp (sel_temp): global tempVal tempVal = sel_temp def converter (rlabel1 , entrada_var , entrada2_var , entrada3_var): tem = entrada_var.get() tem2 =entrada2_var.get() tem3 =entrada3_var.get() taxa_elim = 0.015 if tempVal == 'Homem' : alcoolemia = (tem / (tem2 * 0.68 )) - (taxa_elim * tem3) rlabel1.config( text = "Sua alcoolémia atual é de aproximadamente %.3f g/dL" %alcoolemia) if tempVal == 'Mulher' : alcoolemia = (tem / (tem2 * 0.55 )) - (taxa_elim * tem3) rlabel1.config( text = "Sua alcoolémia atual é de aproximadamente %.3f g/dL" % alcoolemia) texto = Label( text = "Quantas gramas de álcool você con...

Meses para acabar com a dívida

from tkinter import * root = Tk() root.geometry( "400x400" ) root.resizable( 0 , 0 ) root.config( bg = "#2c6a99" ) root.title( "Meses para acabar com a dívida" ) titulo = Label( text = "Meses para acabar com a dívida" , font =( "Arial" , "18" , "bold" ) , bg = "#2c6a99" , fg = "#18dbbe" ) titulo.place( relx = 0.05 , rely = 0.05 ) texto_sub1 = Label( text = "Valor Divída Total :" , font =( "Arial" , "16" , "bold" ) , bg = "#2c6a99" , fg = "#18dbbe" ) texto_sub1.place( relx = 0.15 , rely = 0.25 ) texto_sub2 = Label( text = "Valor da Renda Mensal:" , font =( "Arial" , "16" , "bold" ) , bg = "#2c6a99" , fg = "#18dbbe" ) texto_sub2.place( relx = 0.05 , rely = 0.45 ) Divída_Total = DoubleVar() Divída_Total_entrada = Entry( textva...