Mensagens

A mostrar mensagens de março, 2021

Criar captcha (Usando jupyter notebook)

from captcha.image import ImageCaptcha import random numero_aleatorio = int(input("Número de caracteres: ")) char_list = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890' passwd = "" while len(passwd) != numero_aleatorio: passwd = passwd + random.choice(char_list) senha = str(passwd) imagem = ImageCaptcha (width=500,height=90) imagem = imagem.create_captcha_image("{}".format(senha),color="white",background="black") imagem.show() guardar = str(senha)+".png" print(guardar) imagem.save('{}'.format(guardar))

Postal de Aniversário (usando pygame)

Imagem
  import pygame pygame.init() display_width = 500 display_height = 350 gameDisplay = pygame.display.set_mode((display_width , display_height)) pygame.display.set_caption( 'Feliz Aniversário' ) black = ( 0 , 0 , 0 ) white = ( 255 , 255 , 255 ) clock = pygame.time.Clock() crashed = False # Imagem retirada no google bolo = pygame.image.load( 'anos.jpg' ) def anos (x , y): gameDisplay.blit(bolo , (x , y)) x = (display_width * 0.05 ) y = (display_height * 0.1 ) def text ( x1 , y1 ): vermelho = ( 255 , 99 , 71 ) azul = ( 135 , 206 , 235 ) font = pygame.font.Font( 'freesansbold.ttf' , 32 ) text = font.render( 'Feliz Aniversário' , True, vermelho , azul) textRect = text.get_rect().center # set the center of the rectangular object. gameDisplay.blit(text , textRect) x1=display_width / 2 y1=display_height / 2 while not crashed: for event in pygame.event.get(): if event.type == pygame.QUIT: crashed = True g...

Código de Aniversário

import time def feliz_aniversario (nome): nome = nome.capitalize() for x in range ( 2 ): print ( "Happy Birthday to you." ) time.sleep( 1 ) print ( "Happy Birthday to you." ) time.sleep( 1 ) print ( "Happy Birthday to" , nome , "!" ) time.sleep( 1 ) print ( "Happy Birthday to you." ) time.sleep( 1 ) for x in range ( 3 ): print ( "Hip Hip Hooray!" ) nome= str ( input ( "Nome do aniversariante:" )) feliz_aniversario(nome)

Calculadora simples\Calculadora muito simplesusando Tkinter

# Calculadora simples def soma (a , b): soma1 = a + b return soma1 def diferanca (a , b): diferanca1 = a - b return diferanca1 def mulpiplicacao (a , b): multi = a*b return multi def divisao (a , b): divisao1 = a/b return divisao1 a = int ( input ( " Escreva o primeiro número: " )) b = int ( input ( " Escreva o segundo número: " )) print ( "A soma é: " , soma(a , b)) print ( "A diferença: " , diferanca(a , b)) print ( "O produto é : " , mulpiplicacao(a , b)) d = round (divisao(a , b) , 2 ) print ( "A divisão é: " , d) # Calculadora Muito Simples Usando Tkinter   from tkinter import * root =Tk() class App(): def __init__ ( self ): self .root = root self .config() self .calculadora() root.mainloop() def config ( self ): self .root.title( "Calculadora muito simples" ) self .root.geometry( "400x250" ) self .root.resi...

Criptografar e Descriptografar (criptografia ou cifra de cesar)

def pergunta (): chave = int ( input ( "Número da chave(apenas números inteiros): " )) return chave def sair (): print ( "Fim do Programa!! " ) quit () def crip (): codificado = [] str = "" mensagem = input ( "Escreva a mensagem para criptografa-la: " ) mensagem = mensagem.lower() chave = pergunta() for letra in mensagem: passou = ord (letra) if passou >= 123 and passou <= 127 : letra1 = chr (passou) codificado.append(letra1) print ( "Passou aqui" ) elif passou >= 32 and passou <= 64 : letra1 = chr (passou) codificado.append(letra1) elif (passou + chave) > 122 : certo = ((passou + chave) - 26 ) letra1 = chr (certo) codificado.append(letra1) else : letra1 = chr (passou + chave) codificado.append(letra1) print (str.join(cod...

Conversor de Velocidade

def sair (): print ( "Sair do Sistema!" ) quit () def quim_milhas (): kmh = int ( input ( "Enter km/h: " )) mph = 0.6214 * kmh print ( "Velocidade:" , kmh , "KM/H = " , mph , "MPH" ) def milhas_quim (): mph = int ( input ( "Enter MPH " )) kmh = mph/ 0.6214 print ( "Velocidade:" , mph , "MPH" , kmh , "KM/H = " ) def menu (): print ( "********* Menu Principal*********" ) escolha = input ( """ A: Converter Quilometros para Milhas B: Converter Milhas para Quilometros C: Sair Escolha uma hipótese: """ ) if escolha == 'A' or escolha == 'a' : quim_milhas() menu() elif escolha == 'B' or escolha == 'b' : milhas_quim() menu() elif escolha == 'C' or escolha == ...

Tabuada

Artigos relacionados: Tabuada usando o tkinter # Tabuada numerador = int ( input ( "Qual o número que quer que se faça a tabuada: " )) print ( " \n " ) for i in range ( 1 , 11 ): r = i*numerador print ( "{} x {} = {}" .format(numerador , i , r)) i = i+ 1

Analisar Criptomoedas (formato em .ipynb)

! pip install yfinance import  numpy  as  nr import  pandas  as  pd import  matplotlib.pyplot  as  plt import  pandas_datareader.data  as  web import  yfinance  as  yf yf.pdr_override() #Carregar os dados das cripto moedas  ltc = web.get_data_yahoo( 'LTC-USD' ) btc = web.get_data_yahoo( 'BTC-USD' ) etr =web.get_data_yahoo( 'ETH-USD' )   #Mostrar os primeiros valores ltc.head()   # Juntar as três moedas df = pd.DataFrame({ 'BTC' : btc[ 'Adj Close' ], 'ETH' : etr[ 'Adj Close' ], 'LTC' : ltc[ 'Adj Close' ] }) df   #Gráfico Crytomoedas import  matplotlib.pyplot  as  plt plt.style.use( 'fivethirtyeight' ) my_crypto = df plt.figure(figsize = ( 12.2 ,  4.5 )) for  c  in  my_crypto.columns.values:    plt.plot(my_crypto[c], label = c) plt.title( 'Gráfico das Cryptomoedas' ) plt.xlabel( 'Dias' ) plt.ylabel( ' Preço Crypto ($)' ) plt.legend(my_crypto.columns.values, loc=  'upper left' )...

Trabalhar com CSV

Ler um arquivo CSV import csv # ler um CSV csvFile = r'C:\Users\utilizador\Desktop\jogo.csv' f= open (csvFile , 'rt' ) myReader = csv.reader(f) for row in myReader: print (row) Criar um arquivo CSV import csv # Esvrever escrever uma linha no novo arquivo targetList=[ "Teste" , "Teste1" , "Teste2" , "Teste3" ] # Criar uma nova CSV with open ( 'newFile.csv' , 'w' , encoding = 'utf-8' , newline = '' ) as csvfile: escrever=csv.writer(csvfile) escrever.writerow(targetList) Escrever num CSV existente. import csv #Escrever num CSV existente e = r'newFile.csv' with open (e , 'a' ) as csvfile: escrever=csv.writer(csvfile) targetList=[ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] escrever.writerow(targetList)