Mensagens

A mostrar mensagens de setembro, 2023

Calcular taxa por 1 milhão habitantes

from tkinter import * root = Tk() root.geometry( "500x400" ) root.resizable( 0 , 0 ) root.config( bg = "#1b5c85" ) root.title( "Calcular taxa por 1 milhão habitantes" ) titulo = Label( text = "Calcular taxa por 1 milhão habitantes" , font =( "Arial" , "18" , "bold" ) , bg = "#1b5c85" , fg = "#91c5e6" ) titulo.place( relx = 0.08 , rely = 0.05 ) texto_sub1 = Label( text = "Número de ocorrências" , font =( "Arial" , "14" , "bold" ) , bg = "#1b5c85" , fg = "#91c5e6" ) texto_sub1.place( relx = 0.09 , rely = 0.25 ) texto_sub2 = Label( text = "Número total de Habitantes" , font =( "Arial" , "14" , "bold" ) , bg = "#1b5c85" , fg = "#91c5e6" ) texto_sub2.place( relx = 0.05 , rely = 0.4 ) Número_ocorrências = IntVar() Número_corrência...

Aplicativo de folha de pagamento simples

from tkinter import * root = Tk() root.geometry( "400x600" ) root.resizable( 0 , 0 ) root.config( bg = "#d9ead3" ) root.title( "Aplicativo de folha de pagamento simples" ) def app (): n = nome.get() chora = custo_por_hora.get() numero_horas = numero_de_horas_trabalhadas.get() ss = Contribuição_SS.get() seguro = Seguro_Saúde.get() emprestimo = emprestimo_casa.get() salario_bruto = chora*numero_horas imposto = salario_bruto* 0.1 total_dedução = imposto + ss + seguro +emprestimo salario_liquido = salario_bruto-total_dedução mensagem = f"Dados de { n } . \n Salário Bruto: { salario_bruto }\n " \ f"Impostos: { imposto }\n Total Gastos: { total_dedução }\n Salário Líquido: { salario_liquido } " resultado.set(mensagem) def limpar (): nome_entrada.delete( 0 , END) custo_por_hora_entrada.delete( 0 , END) emprestimo_casa_entrada.delete( 0 , END) Seguro_Saúde_entrada...

Tarefa aleatória

import random from tkinter import * root = Tk() root.geometry( "300x300" ) root.resizable( 0 , 0 ) root.config( bg = "#0e5669" ) root.title( "Tarefa aleatória" ) titulo = Label( text = "Tarefa Aleatória" , font =( "Arial" , "25" , "bold" ) , bg = "#0e5669" , fg = "#86d0e3" ) titulo.place( relx = 0.08 , rely = 0.05 ) def app (): tarefas = [ "Ler um livro" , "Fazer exercícios" , "Assistir a um filme" , "Cozinhar o jantar" , "Limpar o quarto" ] tarefa_aleatoria = random.choice(tarefas) mensagem = f" Tarefa aleatória do dia: \n { tarefa_aleatoria } " resultado.set(mensagem) but1 = Button( text = "Tarefas" , bd = 2 , bg = '#107db2' , fg = 'white' , font =( 'verdana' , 15 , 'bold' ) , command =app) but1.place( relx = 0.25 , rely = 0.3 , relwidth = 0.45 , relh...

Simulação de Luz

import tkinter as tk class luzsimulador: def __init__ ( self , root): self .root = root self .root.title( "Simulador de Luz" ) self .luz_amarela1 = tk.Canvas(root , width = 50 , height = 50 , bg = "yellow" ) self .luz_amarela1.grid( row = 0 , column = 2 , padx = 5 , pady = 5 ) self .luz_amarela2 = tk.Canvas(root , width = 50 , height = 50 , bg = "gray" ) self .luz_amarela2.grid( row = 1 , column = 2 , padx = 5 , pady = 5 ) self .luz_amarela3 = tk.Canvas(root , width = 50 , height = 50 , bg = "gray" ) self .luz_amarela3.grid( row = 2 , column = 2 , padx = 5 , pady = 5 ) self .luz_amarela4 = tk.Canvas(root , width = 50 , height = 50 , bg = "gray" ) self .luz_amarela4.grid( row = 3 , column = 2 , padx = 5 , pady = 5 ) self .estado_atual = 0 self .mudar_estado() def mudar_estado ( self ): if self .estado_atual == 0 : s...

Diferença entre eleições

from tkinter import * root = Tk() root.geometry( "400x400" ) root.resizable( 0 , 0 ) root.config( bg = "#224885" ) root.title( "Diferença entre eleições" ) titulo = Label( text = "Diferença entre eleições de deputados" , font =( "Arial" , "15" , "bold" ) , bg = "#224885" , fg = "#a9d0db" ) titulo.place( relx = 0.05 , rely = 0.05 ) texto_sub1 = Label( text = "Última Eleição" , font =( "Arial" , "12" , "bold" ) , bg = "#224885" , fg = "#a9d0db" ) texto_sub1.place( relx = 0.15 , rely = 0.3 ) texto_sub2 = Label( text = "Eleição Actual" , font =( "Arial" , "12" , "bold" ) , bg = "#224885" , fg = "#a9d0db" ) texto_sub2.place( relx = 0.55 , rely = 0.3 ) Última_Eleição = IntVar() Última_Eleição_entrada = Entry( textvariable =Última_...

Arranjar senha aleatória

import random numeros_aleatorios = [random.randint( 1 , 9 ) for _ in range ( 4 )] output = " " .join( map ( str , numeros_aleatorios)) print (output)

Verificar se é maior de idade

from tkinter import * root = Tk() root.geometry( "350x350" ) root.resizable( 0 , 0 ) root.config( bg = "#1b6e8f" ) root.title( "Maior de idade" ) titulo = Label( text = "Maior de Idade" , font =( "Arial" , "34" , "bold" ) , bg = "#1b6e8f" , fg = "#19e3cb" ) titulo.place( relx = 0.05 , rely = 0.05 ) texto_sub1 = Label( text = "Idade:" , font =( "Arial" , "18" , "bold" ) , bg = "#1b6e8f" , fg = "#19e3cb" ) texto_sub1.place( relx = 0.25 , rely = 0.3 ) idade = IntVar() idade_entrada = Entry( textvariable =idade , font =( "Arial" , "12" , "bold" ) , bg = "white" , fg = "blue" , justify = 'center' ) idade_entrada.place( relx = 0.5 , rely = 0.3 , relwidth = 0.25 ) def limpar (): idade_entrada...

Soma de uma Série Aritmética

print ( "Soma de uma Série Aritmética" ) a1 = int ( input ( "Digite o primeiro termo: " )) an = int ( input ( "Digite o último termo: " )) n = int ( input ( "O número de termos sendo adicionados: " )) d = a1 + an t = d/ 2 sn = n*t print ( f"A Soma de uma Série Aritmética é de { sn } ." )

Soma da percentagem

numero_percentagem_somar = int ( input ( "Digite o número de percentagens a somar: " )) contar = 1 soma = 0 while contar <= numero_percentagem_somar: percentagem = float ( input ( f"Digite a percentagem número { contar } : " )) soma += percentagem if soma > 100 : print ( "Já excedeu os 100%." ) break print ( f"A soma da percentagem até agora é de { soma } %." ) contar += 1 if soma < 100 : print ( "Erro! A soma não chegou aos 100%." )

Marcha

import time marcha = int ( input ( "Digite o número de passos que você deseja dar: " )) for contar in range ( 1 , marcha + 1 ): if contar % 2 == 0 : print ( f"Esquerda" ) else : print ( f"Direita" ) if contar < marcha: time.sleep( 2 )

Massa Corporal Total

from tkinter import * root = Tk() root.geometry( "400x400" ) root.resizable( 0 , 0 ) root.config( bg = "#226770" ) root.title( "Massa Corporal Total" ) titulo = Label( text = "Massa Corporal Total" , font =( "Arial" , "27" , "bold" ) , bg = "#226770" , fg = "#cedee0" ) titulo.place( relx = 0.05 , rely = 0.05 ) texto_sub1 = Label( text = "Massa Corporal Total (em kg):" , font =( "Arial" , "13" , "bold" ) , bg = "#226770" , fg = "#cedee0" ) texto_sub1.place( relx = 0.05 , rely = 0.25 ) texto_sub2 = Label( text = "Massa Magra (em kg):" , font =( "Arial" , "13" , "bold" ) , bg = "#226770" , fg = "#cedee0" ) texto_sub2.place( relx = 0.2 , rely = 0.45 ) mct= DoubleVar() mct_entrada = Entry( textvariable =mct , ...

Estação do Ano

from datetime import date import time escolha= True while escolha: print ( " \n " ) print ( " \033 [1;36m= \033 [m" * 60 ) print ( " \t\t\t\t\t Estação do Ano" ) print ( " \033 [1;36m= \033 [m" * 60 ) print ( """ 1. \t Estações do Ano \n 2. \t Actual Estação do Ano \n 3. \t Estação do Ano de uma data qualquer \n 4. \t Exit/Quit/Saída """ ) escolha= input ( "Escolha uma opção: " ) if escolha== "1" : time.sleep( 2 ) print ( " \n " ) print ( " \033 [1;34mPrimavera: \033 [m \033 [1;93m20 de março a 21 de junho \033 [m" ) print ( " \033 [1;94mVerão: \033 [m \033 [1;92m21 de junho a 23 de setembro \033 [m" ) print ( " \033 [1;91mOutono: \033 [m \033 [1;33m23 de setembro a 21 de dezembro \033 [m" ) print ( " \033 [1;96mInverno: \033 [m \033 [1;34m21 de dezembro a 2...