Mensagens

A mostrar mensagens de junho, 2022

Mad Libs Generator Game

nome = str ( input ( " Nome Masculino: " )) adj1 = str ( input ( " Adjectivo 1: " )) adj2 = str ( input ( " Adjectivo 2: " )) act1= str ( input ( " Actividade 1: " )) act2= str ( input ( " Actividade 2: " )) act3= str ( input ( " Actividade 3: " )) subs1 = str ( input ( " Substantivo 1: " )) subs2 = str ( input ( " Substantivo 2: " )) subs3 = str ( input ( " Substantivo 3: " )) lugar1 = str ( input ( " Lugar 1: " )) lugar2 = str ( input ( " Lugar 2: " )) print ( 'O ' , nome , 'é um' , adj1 , subs1 , " que vive em " , lugar1 , 'e é de um ' , adj2 , 'da família' , 'Ele mora com seu' , subs2 , 'quem é o ganha-pão da família. \n ' 'Ela ganha ' , subs3 , 'pela ' , act1 , 'no Continente. \n Quando ' , nome , 'tem tempo livre faz ' , act2 , ' e...

Desconto simples comercial

Esse desconto, por sua vez, é aquele no qual a taxa de desconto incide sempre sobre o montante, ou o valor futuro. Inclusive, é amplamente utilizado em descontos de duplicatas, realizados por bancos. # Valor do desconto valor_nominal = float ( input ( 'Valor nominal do título: ' )) taxa_desconto = float ( input ( 'Valor do desconto (em %):' )) taxa_descontoper = taxa_desconto/ 100 tempo = int ( input ( 'Tempo (antecipação do desconto): ' )) # d = N * i * n d = valor_nominal*taxa_descontoper*tempo valor_actual = valor_nominal - round (d , 2 ) print ( f"O valor do desconto é { round (d , 2 ) } \n " f"O valor actual é de { valor_actual } ." )  

Desconto simples racional

# Esse desconto também pode ser chamado de “desconto por dentro” ou “desconto real”. Resumidamente, é o equivalente ao juro produzido pelo valor atual de um título. Considerando, ainda, a taxa fixada e o tempo correspondente.  #Desconto simples racional vm = float ( input ( "Valor nominal: " )) i = float ( input ( "Taxa de Descunto (em %): " )) iper = i* 100 n = int ( input ( "Quantidade de períodos: " )) valoractual = vm/( 1 +iper*n) desconto = vm - round (valoractual , 2 ) print ( f"O desconto é de { desconto } euros. " )

Custo marginal

variacaoct = float ( input ( "Variação do Custo de Trabalho: " )) variacaoquantidade = float ( input ( "Variação do Custo de Trabalho: " )) customargina = variacaoct/variacaoquantidade customarginaarr = round (customargina , 2 ) print ( f'O custo marginal é de { customarginaarr } ' )

Atenção.

Por motivos pessoais não vou poder fazer posts com frequência. No mês de julho apenas irei postar 1 vez por semana. Agosto não vai ter nenum post.

Custo Médio Ponderado

custocompra = float ( input ( "Custo da compra: " )) quantidadecompra = int ( input ( "Quantidade da compra: " )) custoanterior = float ( input ( "Custo anterior do item: " )) quantidadestock = int ( input ( "Quantidade em stock: " )) customédio = ((custocompra*quantidadecompra)+(custoanterior*quantidadestock))\ /(quantidadecompra+quantidadestock) custoarr = round (customédio , 2 ) print ( f"O custo médio { custoarr } ." )

Localizar aonde está a bola

import random aleatorio = random.sample( range ( 1 , 3 ) , 1 ) escolha_copo = int ( input ( "Adivinhe o copo em que está a bola[ 1 a 3] : " )) if escolha_copo ==aleatorio: print ( "Parabéns, acertou na bola" ) else : print ( "Upps! Errou!" )

Ler QR Code

import cv2 from pyzbar import pyzbar cap = cv2.VideoCapture( 0 ) while True : ret , frame = cap.read() frame = cv2.resize(frame , ( 600 , 600 )) font = cv2.FONT_HERSHEY_SIMPLEX cv2.putText(frame , 'Press q to close camera' , ( 15 , 25 ) , font , 0.6 , ( 0 , 255 , 255 ) , 1 ) data = pyzbar.decode(frame) for xywh in data: (x , y , w , h) = xywh.rect cv2.rectangle(frame , (x , y) , (x + w , y + h) , ( 255 , 0 , 255 ) , 2 ) text = data[ 0 ].data.decode( 'utf-8' ) cv2.putText(frame , text , (x , y - 50 ) , font , 0.8 , ( 255 , 0 , 255 ) , 2 ) cv2.imshow( "QR code scanner" , frame) if cv2.waitKey( 1 ) == ord ( 'q' ): break cap.release() cv2.destroyAllWindows()

Radar Velocidade (usando tkinter)

Imagem
from tkinter import * from PIL import Image , ImageTk root = Tk() img1=ImageTk.PhotoImage(Image.open( "feliz.png" )) img2=ImageTk.PhotoImage(Image.open( "azangado.png" )) def app (): ve = velocidade.get() if ve <= 50 : l.config( image =img1) else : l.config( image =img2) root.title( "velocidade" ) root.geometry( "300x300" ) root.configure( background = "white" ) root.resizable( False,False ) velocidade = IntVar() entrar_velocidade = Label( text = 'Introduza a velocidade:' , font =( "Arial" , "12" , "bold" )) entrar_velocidade.place( relx = 0.05 , rely = 0.05 ) introduzir_velocidade = Entry( textvariable =velocidade , justify = 'center' ) introduzir_velocidade.place( relx = 0.73 , rely = 0.06 , relwidth = 0.2 ) bt = Button(root , text = "Verificar" , bg = '#03fccf' , font =( "Arial...

Verificação captcha

from tkinter import * from tkinter import messagebox import random text = 'abcdefghijklmnopqrstuvwxyz0123456789' root = Tk() root.title( "Verificação de Captcha App" ) root.geometry( "300x200" ) root.resizable( False,False ) captcha = StringVar() chave = StringVar() def create_captcha (): c = random.choices(text , k = 5 ) captcha.set( '' .join(c)) def check (): if captcha.get() == chave.get(): messagebox.showinfo( 'Verificação Captcha ' , 'Verificado com Sucesso' ) else : messagebox.showerror( 'Verificação Captcha' , 'Incorrecto' ) chave.set( '' ) create_captcha() teste = Label( textvariable =captcha , font =( "ariel" , "16" , "bold" )) teste.place( relx = 0.4 , rely = 0.1 ) entrada = Entry( textvariable =chave , bg = 'white' , font =( "ariel" , "12" , "bold" ) , justify = 'center' ) entrada.place...

Saber o dia da semana (usando Tkinter)

from tkinter import * import datetime import calendar root =Tk() class app(): def __init__ ( self ): self .root = root self .janela() self .dataaapp() root.mainloop() def janela ( self ): self .root.title( "Dia da Semana " ) self .root.geometry( "400x200" ) self .root.resizable( False, False ) self .root.configure( background = '#eaeef5' ) def dataaapp ( self ): self .data = StringVar() self .data_lb = Label( text = " Dia em formato dd/mm/yyyy: " , font =( "Helvetica" , '10' , 'bold' ) , bg = '#78c8c0' , fg = '#0a0fc9' ) self .data_lb.place( relx = 0.05 , rely = 0.05 ) self .data_entry = Entry( textvariable = self .data , justify = 'center' ) self .data_entry.place( relx = 0.55 , rely = 0.06 , relwidth = 0.35 ) ...

imprimir Emojis

# Lista de códigos de emoji: # https://unicode.org/emoji/charts/full-emoji-list.html #Exemplo print ( ' \U0001F602 ' ) print ( ' \U0001F605 ' ) print ( ' \U0001F60D ' ) print ( ' \U0001F92A ' ) print ( ' \U0001F92B ' ) print ( ' \U0001F498 ' )   😊 (U+1F60A) - Rosto Sorridente com Olhos Sorridentes 😎 (U+1F60E) - Rosto com Óculos de Sol 🥰 (U+1F970) - Rosto Sorridente com Olhos de Coração 😢 (U+1F622) - Rosto Chorando 😡 (U+1F621) - Rosto com Raiva 🤣 (U+1F923) - Rosto Rindo às Gargalhadas 😴 (U+1F634) - Rosto Dormindo 🤔 (U+1F914) - Rosto Pensativo 😋 (U+1F60B) - Rosto Saboreando Comida Deliciosa 🤩 (U+1F929) - Rosto com Olhos Brilhando de Estrela 😇 (U+1F607) - Rosto Sorridente com Auréola 😂 (U+1F602) - Rosto com Lágrimas de Alegria   😅 (U+1F605) - Rosto com Lágrimas de Alegria e Suor 😍 (U+1F60D) - Rosto com Olhos de Coração 🤪 (U+1F92A) - Rosto com Olhos Girando 🤫 (U+1F92B) - Rosto com Dedo na Boc 💘 (U+1F498) - Coração com Flecha ...

Buscar Informação através da Wikipédia (Usando tkinter)

# As palavras de pesquisa têm de ser em inglês from tkinter import * from wikipedia import summary import tkinter.scrolledtext as scrolledtext root =Tk() class app(): def __init__ ( self ): self .root = root self .janela() self .pesquisaapp() root.mainloop() def janela ( self ): self .root.title( "Pesquisar Palavras Wikipedia " ) self .root.geometry( "600x600" ) self .root.resizable( False, False ) self .root.configure( background = '#eaeef5' ) def pesquisaapp ( self ): self .palavra = StringVar() self .palavra_lb = Label( text = " Palavra a procurar: " , font =( "Helvetica" , '10' , 'bold' ) , bg = '#78c8c0' , fg = '#0a0fc9' ) self .palavra_lb.place( relx = 0.05 , rely = 0.05 ) self .palavra_entry = Entry( textvariable = self .palav...

Mini Jogo

from tkinter import * root =Tk() class app(): def __init__ ( self ): self .root = root self .janela() self .minojogo() root.mainloop() def janela ( self ): self .root.title( "Mini Jogo" ) self .root.geometry( "300x250" ) self .root.configure( background = 'Gray' ) self .root.resizable( False, False ) def minojogo ( self ): self .v = StringVar() self .pergunta_lb = Label( textvariable = self .v , font =( "Helvetica" , '20' )) self .pergunta_lb.place( relx = 0.2 , rely = 0.15 ) self .v.set( "Quanto é 1 + 1 ?" ) self .um = Button( text = "1" , font =( "Helvetica" , 20 ) , command = self .um) self .um.place( relx = 0.25 , rely = 0.4 ) self .dois = Button( text = "2" , font =( "Helvetica" , 20 ) , command = self .dois) self ...

Jogar o Jogo Maior ou Menor

import random pontos = 0 numero = random.randint( 1 , 100 ) resp = 's' while resp == 's' : print (numero) numerio_aleatorio = random.randint( 1 , 30 ) numero_escolhido = str ( input ( "Maior [Ma] ou Menor [Me] : " )).lower() if numerio_aleatorio == numero: print ( "Não é nem maior nem menor" ) elif numerio_aleatorio > numero: print ( f"O { numerio_aleatorio } é maior que { numero } " ) if numero_escolhido == 'ma' : pontos = pontos + 1 print ( f"Os actuais pontos é { pontos } " ) else : pontos = pontos - 1 print ( f"Os actuais pontos é { pontos } " ) else : print ( f"O { numerio_aleatorio } é menor que { numero } " ) if numero_escolhido == 'me' : pontos = pontos + 1 print ( f"Os actuais pontos é { pontos } " ) else : pon...

Cheklist (usando Tkinter)

root = Tk() class app(): def __init__ ( self ): self .root = root self .janela() self .Checkbutton_tutorial() # criando o Loop root.mainloop() def janela ( self ): self .root.title( "Cheklist" ) self .root.configure( background = '#B0C4DE' ) self .root.geometry( "350x250" ) self .root.resizable( False, False ) def Checkbutton_tutorial ( self ): self .Checkbutton1 = IntVar() self .Checkbutton2 = IntVar() self .Checkbutton3 = IntVar() self .Checkbutton4 = IntVar() self .Button1 = Checkbutton(root , text = "Tomar Pequeno-Almoço" , variable = self .Checkbutton1 , onvalue = 1 , offvalue = 0 ) self .Button1.place( relx = 0.3 , rely = 0.1 ) self .Button2 = Checkbutton(root , text = "Tomar Banho" , ...

Média de Notas

  # Versão Portugal notas = [] nunota = 1 contador = 0 numero_notas = int ( input ( "Número de Notas: " )) while numero_notas != contador: nota = float ( input ( "Digite a nota " + str (nunota)+ str ( ": " ))) notas.append(nota) contador = contador + 1 nunota = nunota + 1 media = sum (notas)/ len (notas) mediaarr1 = round (media , 2 ) mediaarr = round (media) if mediaarr>= 10 : print ( f' \033 [1;32mO aluno foi aprovado com uma média de { mediaarr1 }\033 [m' ) else : print ( f' \033 [1;31mO aluno foi reprovado com uma média de { mediaarr1 }\033 [m' )

Velocidade Média de uma Partícula

# Velocidade Média import time print ( "Vamos Calcular a Velociade Média" ) variacao_de_espaco = float ( input ( "Valor da Variação de Espaço em metros: " )) variacao_de_temporal = float ( input ( "Valor da Variação Temporal em segundos: " )) print ( "A calcular....." ) time.sleep( 5 ) velocidade_media = (variacao_de_espaco/variacao_de_temporal) print ( f"A Velocidade Média nesse Sistema é de: { velocidade_media } " )

Impacto da variação de preços das matérias-primas no preço total (usando Tkinter)

from tkinter import * root =Tk() class app(): def __init__ ( self ): self .root = root self .janela() self .login() root.mainloop() def janela ( self ): self .root.title( "Factores de Produção Interferem no Preço" ) self .root.geometry( "700x600" ) self .root.configure( background = '#d9f1ff' ) self .root.resizable( False, False ) def login ( self ): self .texto_lb = Label( text = " % da matéria-prima em relação ao produto" , font =( "Helvetica" , '10' )) self .texto_lb.place( relx = 0.05 , rely = 0.05 ) # Matéria-Prima self .materiaprima1 = DoubleVar() self .materiaprima1_lb = Label( text = " Matéria-Prima 1: " , font =( "Helvetica" , '10' )) self .materiaprima1_lb.place( relx = 0.05 , rely = 0.15 ) ...

Validar cartão cidadão (usando tkinter)

from tkinter import * def getNumberFromChar (letra): charDict = { "0" : "0" , "1" : "1" , "2" : "2" , "3" : "3" , "4" : "4" , "5" : "5" , "6" : "6" , "7" : "7" , "8" : "8" , "9" : "9" , "A" : "10" , "B" : "11" , "C" : "12" , "D" : "13" , "E" : "14" , "F" : "15" , "G" : "16" , "H" : "17" , "I" : "18" , "J" : "19" , "K" : "20" , "L" : "21" , "M" : "22" , "N" : "23" , "O" : "24" , "P" : "25" , "Q" : "26" , ...