Mensagens

A mostrar mensagens de setembro, 2022

Jogo do Par ou Impar (usando Tkinter)

from tkinter import * from random import randint root = Tk() root.geometry( "400x250" ) root.title( "Jogo Par ou Impar" ) root.configure( bg = "white" ) root.resizable( False,False ) def jogar (): e = opcao.get().lower().strip()[ 0 ] n = numero.get() pc = randint( 0 , 10 ) total = n +pc if n <= 10 : if e == 'p' or e == 'i' : if e in 'p' : if total % 2 == 0 : mensagem = f'Jogou { n } , o computador jogou { pc } . Total igual { total } .' \ f' \n Parabéns, ganhou.' else : mensagem = f'Jogou { n } , o computador jogou { pc } . Total igual { total } .' \ f' \n Lamento, mas perdeu.' if e in 'i' : if total % 2 == 1 : mensagem = f'Jogou { n } , o computador jogou { pc } . To...

Calculadora (dois números usando tkinter)

from tkinter import * from tkinter import ttk root = Tk() root.title( "Calculadora" ) root.geometry( "300x300" ) root.resizable( 0 , 0 ) root.configure( bg = '#45aaf2' ) def limpar1 (): entrada1.delete( 0 , END) entrada2.delete( 0 , END) def calculadora (): num1 = numero1.get() num2 = numero2.get() opr = combobox.get() if opr == '+' : result = num1 + num2 elif opr == '-' : result = num1 - num2 elif opr == 'x' : result = num1 * num2 elif opr == '/' : result = num1 / num2 resultado.set(result) numero1=DoubleVar() numero2=DoubleVar() entrada1 = Entry( textvariable =numero1 , font =( 'verdana' , 16 ) , justify = 'center' ) entrada1.place( relx = 0.45 , rely = 0.05 , relwidth = 0.4 ) nentrada1 = Label( text = "Número 1" , font =( 'verdana' , 12 , 'bold' ) , justify = 'center' , bg = '#45aaf2' ) nentrada1...

Sistema de Restaurante

from tkinter import * from tkinter import filedialog, messagebox import time root = Tk() root.geometry('1400x600') root.resizable(0, 0) root.title(' Sistema de Restaurante') def quit():       root.quit() def limpar():      textbatatasfrias.delete(0, END)      textcachorro.delete(0, END)      texthamburger.delete(0, END)      textcompal.delete(0, END)      texticetea.delete(0, END)      textcola.delete(0, END)      textnatas.delete(0, END)      textbrigadeiro.delete(0, END)      textcroissant.delete(0, END)      resultadof.delete('1.0', END)      resultadofiva.delete('1.0', END)     resultadofsemiva.delete('1.0', END)     resultadoftotaldocomida.delete('1.0', END)    txt.delete('1.0', END) def totalapp():       bfritas = vbatatasfrias.get()      cocacola =vcola.get()       cachorroquente= vcachorro.get()    hamburgerquente =vhamburger.get()    bcompal=vcompal.get()    bice=vice.get()    dnatas=vnatas.get()    dbrigadeiros=vbrigadei...

Jogo de Snake (cobra) - Water (àgua) - Gun (arma)

import random def app(): n = int ( input ( 'Número de Jogadas: ' )) print( "Regras do Jogo \n\t Cobra bebe a água (Ganha a cobra contra a água)" " \n\t A arma vai afundar na água " "(Ganha a água contra a arma) \n\t " "Arma vai matar a cobra(Ganha a água contra a arma)" ) print( "Snake (cobra) - Water (àgua) - Gun (arma)" ) opcao = [ 's' , 'w' , 'g' ] ronda = 1 vitoria_comp = 0 vitoria_jogador = 0 while n >=ronda: computador = random.choice(opcao) print(computador) jogada = str(input( f"Ronda { ronda } : Escolha Cobra[s],Àgua[w] ou Arma [g]: " )) if jogada != 's' and jogada != 'w' and jogada != 'g' : print( "Escolha inválido \n " ) continue if computador == 's' : if jogada == 's' : print( ...

preço a pagar pelo fornecimento de energia elétrica

#+---------------------------------------+ #| Preço por tipo e faixa de consumo | #+---------------------------------------+ #| Tipo | Faixa (kWh) | Preço | #+=======================================+ #| Residencial | Até 500 |$ 0,40 | #| | Acima de 500 | 0,65 | #+---------------------------------------+ #| Comercial | Até 1000 | 0,55 | #| | Acima de 1000 | 0,60 | #+---------------------------------------+ #| Industrial | Até 5000 | 0,55 | #| | Acima de 5000 | 0,60 | #+---------------------------------------+ def app (): consumo = int ( input ( "Consumo em kWh: " )) categoria_consumo = str ( input ( "Digite o seu tipo de consumo:" " \n [R]- Residência \n " "[C]- Comercial \n [I]- Industrial \n " "Digite a sua opção: " )).upper() if categoria_consumo == 'R' : if consumo <= 500 : preço = 0.40 ...

Calculadora muito muito simples restaurantes (usando tkinter)

from tkinter import * root = Tk() root.geometry( '500x600' ) root.resizable( 0 , 0 ) root.title( 'Calculadora muito Simples' ) titulo = Label( text = "Calculadora muito Simples " , font =( 'arial' , 18 , 'bold' ) , bg = 'firebrick4' , fg = "#d4af37" ) titulo.place( relx = 0.2 , rely = 0.05 ) def vpao1 (): if var1.get() == 1 : textpao.config( state =NORMAL) textpao.focus() textpao.delete( 0 , END) elif var1.get() == 0 : textpao.config( state =DISABLED) textpao.set( '0' ) def vfiambre1 (): if var2.get() == 1 : textfiambre.config( state =NORMAL) textfiambre.focus() textfiambre.delete( 0 , END) elif var2.get() == 0 : textfiambre.config( state =DISABLED) textfiambre.set( '0' ) def vnatas1 (): if var3.get() == 1 : textnatas.config( state =NORMAL) textnatas.focus() textnatas.delete( 0 , END) ...

Conta de restaurante simples (usando tkinter)

from tkinter import * root = Tk() root.geometry( '800x650' ) root.resizable( 0 , 0 ) root.title( 'Programa Simples Restaurante' ) titulo = Label( text = "Programa Simples Restaurante " , font =( 'arial' , 18 , 'bold' ) , bg = 'firebrick4' , fg = "#d4af37" ) titulo.place( relx = 0.3 , rely = 0.05 ) def vbatatasfrias1 (): if var1.get() == 1 : textbatatasfrias.config( state =NORMAL) textbatatasfrias.focus() textbatatasfrias.delete( 0 , END) elif var1.get() == 0 : textbatatasfrias.config( state =DISABLED) textbatatasfrias.set( '0' ) def vcachorro1 (): if var2.get() == 1 : textcachorro.config( state =NORMAL) textcachorro.focus() textcachorro.delete( 0 , END) elif var2.get() == 0 : textcachorro.config( state =DISABLED) textcachorro.set( '0' ) def vhamburge1 (): if var3.get() == 1 : texthamburger.config( state ...