This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import date | |
| anonas = int(input('Informe o ano que você nasceu: ')) | |
| anoatual = date.today().year | |
| idade = anoatual - anonas | |
| if idade < 18: | |
| falta = 18 - idade | |
| print('Você não tem 18 anos. Falta {} anos.'.format(falta)) | |
| elif idade == 18: | |
| print('Você tem que se alistar.') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| preco = float(input('Informe o valor do produto R$ ')) | |
| print('Qual será a forma de pagamento? \n 1 - À vista dinheiro | cheque \n 2 - À vista no cartão \n 3 - Em até 2x no cartão \n 4 - 3x ou mais no cartão') | |
| formapag = int(input('Digite a forma de pagamento: ')) | |
| # 1 - À vista dinheiro | cheque: 10% desconto | |
| if formapag == 1: | |
| valor = preco - (preco * (10/100)) | |
| # 2 - À vista no cartão: 5% de desconto | |
| elif formapag == 2: | |
| valor = preco - (preco * (5/100)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| numero = int(input('Digite um número: ')) | |
| # Resto da divisão por 2 | |
| resultado = numero % 2 | |
| if resultado == 0: | |
| print('{} é PAR'.format(numero)) | |
| else: | |
| print('{} é ÍMPAR'.format(numero)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| velocidade = float(input('Informe a velocidade do carro: ')) | |
| if velocidade > 80: | |
| print('Você foi multado! O limite é de 80KM/h') | |
| # Quanto passou do limite. Multa custa R$ 7,00 por KM acima do limite | |
| multa = (velocidade - 80) * 7 | |
| print('A multa custara R${:.2f}'.format(multa)) | |
| else: | |
| print('Não ultrapasse a velocidade permitida!') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from random import randint | |
| # Sorteia o número | |
| numero = randint(0,5) | |
| print('') | |
| print('Vou sortear um número de 0 a 5.') | |
| print('') | |
| usuario = int(input('Qual será o número?: ')) | |
| if usuario == numero: | |
| print('Parabéns você acertou!') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| frase = input('Informe uma frase: ') | |
| print('Letra A: ', frase.lower().count('a'), 'vezes', '|', 'Letra E: ', frase.lower().count('e'), 'vezes') | |
| print('Letra I: ', frase.lower().count('i'), 'vezes', '|', 'Letra O: ', frase.lower().count('o'), 'vezes') | |
| print('Letra U: ', frase.lower().count('u'), 'vezes') | |
| posicao = frase.split(" ") | |
| print('A primeira letra é: ', frase[0].upper()) | |
| print('A ultima letra é: ', frase[-1].upper()) | |
| print(len(frase.split(" "))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import datetime | |
| dia_a = datetime.datetime.now() | |
| qtd_dia = dia_a.strftime("%j") | |
| falta = datetime.ye - float(qtd_dia) | |
| print('Falta {:.0f} dias para o Ano Novo'.format(falta)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| nome = input('Informe seu nome completo: ') | |
| print('Quantidade de Letras com espaço: ', len(nome)) | |
| print('Quantidade de Letras sem espaço: ', len(nome.replace(" ", ""))) | |
| print('Nome em minuscula:', nome.lower()) | |
| print('Nome em maiscula:', nome.upper()) | |
| lista = nome.split(" ") | |
| print(lista[0]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| print('Empresa Fast Car') | |
| km = float(input('Informe a quantidade de KM percorridos: ')) | |
| dias = float(input('Informa a quantidade de dias: ')) | |
| valor_km = km * 0.15 | |
| valor_dia = dias * 60 | |
| print('O valor de KM é R$ {:.2f}'.format(valor_km)) | |
| print('O valor de dias é R$ {:.2f}'.format(valor_dia)) | |
| print('O total a ser pago é R$ {:.2f}'.format(valor_km + valor_dia)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| print('Empresa Tinta Seca') | |
| altura = float(input('Digite a altura da parede: ')) | |
| largura = float(input('Digite a largura da parede: ')) | |
| area = altura * largura | |
| print('Será necessário {:.2f} latas de tintas'.format(area / 2)) |