forked from digitalinnovationone/trilha-python-dio
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0557b9
commit a5c904c
Showing
23 changed files
with
384 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
print(int(1.97348728)) | ||
print(int("10")) | ||
print(float("10.10")) | ||
print(float(100)) | ||
|
||
valor = 10 | ||
valor_str = str(valor) | ||
print(type(valor)) | ||
print(type(valor_str)) | ||
|
||
print(100 / 2) | ||
print(100 // 2) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
menu = """ | ||
[d] Depositar | ||
[s] Sacar | ||
[e] Extrato | ||
[q] Sair | ||
=> """ | ||
|
||
saldo = 0 | ||
limite = 500 | ||
extrato = "" | ||
numero_saques = 0 | ||
LIMITE_SAQUES = 3 | ||
|
||
while True: | ||
|
||
opcao = input(menu) | ||
|
||
if opcao == "d": | ||
valor = float(input("Informe o valor do depósito: ")) | ||
|
||
if valor > 0: | ||
saldo += valor | ||
extrato += f"Depósito: R$ {valor:.2f}\n" | ||
|
||
else: | ||
print("Operação falhou! O valor informado é inválido.") | ||
|
||
elif opcao == "s": | ||
valor = float(input("Informe o valor do saque: ")) | ||
|
||
excedeu_saldo = valor > saldo | ||
|
||
excedeu_limite = valor > limite | ||
|
||
excedeu_saques = numero_saques >= LIMITE_SAQUES | ||
|
||
if excedeu_saldo: | ||
print("Operação falhou! Você não tem saldo suficiente.") | ||
|
||
elif excedeu_limite: | ||
print("Operação falhou! O valor do saque excede o limite.") | ||
|
||
elif excedeu_saques: | ||
print("Operação falhou! Número máximo de saques excedido.") | ||
|
||
elif valor > 0: | ||
saldo -= valor | ||
extrato += f"Saque: R$ {valor:.2f}\n" | ||
numero_saques += 1 | ||
|
||
else: | ||
print("Operação falhou! O valor informado é inválido.") | ||
|
||
elif opcao == "e": | ||
print("\n================ EXTRATO ================") | ||
print("Não foram realizadas movimentações." if not extrato else extrato) | ||
print(f"\nSaldo: R$ {saldo:.2f}") | ||
print("==========================================") | ||
|
||
elif opcao == "q": | ||
break | ||
|
||
else: | ||
print("Operação inválida, por favor selecione novamente a operação desejada.") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
conta_normal = False | ||
conta_universitaria = False | ||
conta_especial = True | ||
|
||
saldo = 2000 | ||
saque = 1500 | ||
cheque_especial = 450 | ||
|
||
if conta_normal: | ||
|
||
if saldo >= saque: | ||
print("Saque realizado com sucesso!") | ||
elif saque <= (saldo + cheque_especial): | ||
print("Saque realizado com uso do cheque especial!") | ||
else: | ||
print("Não foi possivel realizar o saque, saldo insuficiente!") | ||
|
||
elif conta_universitaria: | ||
|
||
if saldo >= saque: | ||
print("Saque realizado com sucesso!") | ||
else: | ||
print("Saldo insuficiente!") | ||
|
||
elif conta_especial: | ||
print("Conta especial selecionada!") | ||
|
||
else: | ||
print("Sistema não reconheceu seu tipo de conta, entre em contato com o seu gerente.") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
saldo = 2000 | ||
saque = 2500 | ||
|
||
status = "Sucesso" if saldo >= saque else "Falha" | ||
|
||
print(f"{status} ao realizar o saque!") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
while True: | ||
numero = int(input("Informe um número: ")) | ||
|
||
if numero == 10: | ||
break | ||
|
||
if numero % 2 == 0: | ||
continue | ||
|
||
print(numero) | ||
|
||
|
||
# for numero in range(100): | ||
|
||
# if numero % 2 == 0: | ||
# continue | ||
|
||
# print(numero, end=" ") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
texto = input("Informe um texto: ") | ||
VOGAIS = "AEIOU" | ||
|
||
|
||
# Exemplo utilizando um iterável | ||
for letra in texto: | ||
if letra.upper() in VOGAIS: | ||
print(letra, end="") | ||
else: | ||
print() # adiciona uma quebra de linha | ||
|
||
|
||
# Exemplo utilizando a função built-in range | ||
for numero in range(0, 51, 5): | ||
print(numero, end=" ") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
opcao = -1 | ||
|
||
while opcao != 0: | ||
opcao = int(input("[1] Sacar \n[2] Extrato \n[0] Sair \n: ")) | ||
|
||
if opcao == 1: | ||
print("Sacando...") | ||
elif opcao == 2: | ||
print("Exibindo o extrato...") | ||
else: | ||
print("Obrigado por usar nosso sistema bancário, até logo!") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
MAIOR_IDADE = 18 | ||
IDADE_ESPECIAL = 17 | ||
|
||
idade = int(input("Informe sua idade: ")) | ||
|
||
if idade >= MAIOR_IDADE: | ||
print("Maior de idade, pode tirar a CHN.") | ||
|
||
if idade < MAIOR_IDADE: | ||
print("Ainda não pode tirar a CNH.") | ||
|
||
|
||
if idade >= MAIOR_IDADE: | ||
print("Maior de idade, pode tirar a CHN.") | ||
else: | ||
print("Ainda não pode tirar a CNH.") | ||
|
||
|
||
if idade >= MAIOR_IDADE: | ||
print("Maior de idade, pode tirar a CHN.") | ||
elif idade == IDADE_ESPECIAL: | ||
print("Pode fazer aulas teóricas, mas não pode fazer aulas práticas.") | ||
else: | ||
print("Ainda não pode tirar a CNH.") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
def sacar(valor): | ||
saldo = 500 | ||
|
||
if saldo >= valor: | ||
print("valor sacado!") | ||
print("retire o seu dinheiro na boca do caixa.") | ||
|
||
print("Obrigado por ser nosso cliente, tenha um bom dia!") | ||
|
||
|
||
def depositar(valor): | ||
saldo = 500 | ||
saldo += valor | ||
|
||
|
||
sacar(1000) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
produto_1 = 20 | ||
produto_2 = 10 | ||
|
||
print(produto_1 + produto_2) | ||
print(produto_1 - produto_2) | ||
print(produto_1 / produto_2) | ||
print(produto_1 // produto_2) | ||
print(produto_1 * produto_2) | ||
print(produto_1 % produto_2) | ||
print(produto_1 ** produto_2) | ||
|
||
x = (10 + 5) * 4 | ||
y = (10 / 2) + 25 * ((2 - 2) ** 2) | ||
print(x) | ||
print(y) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
frutas = ["limao", "uva"] | ||
curso = "Curso de python" | ||
|
||
print("laranja" not in frutas) | ||
print("limao" in frutas) | ||
print("Python" in curso) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
saldo = 500 | ||
print(saldo) | ||
|
||
saldo = 200 | ||
print(saldo) | ||
|
||
saldo += 10 | ||
print(saldo) | ||
|
||
saldo -= 5 | ||
print(saldo) | ||
|
||
saldo //= 2 | ||
print(saldo) | ||
|
||
saldo /= 2 | ||
print(saldo) | ||
|
||
saldo *= 10 | ||
print(saldo) | ||
|
||
saldo %= 4 | ||
print(saldo) | ||
|
||
saldo **= 2 | ||
print(saldo) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
saldo = 200 | ||
saque = 200 | ||
|
||
print(saldo == saque) | ||
print(saldo != saque) | ||
print(saldo > saque) | ||
print(saldo >= saque) | ||
print(saldo < saque) | ||
print(saldo <= saque) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
saldo = 1000 | ||
limite = 1000 | ||
|
||
print(saldo is limite) | ||
print(saldo is not limite) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# AND = para ser True tudo tem que ser True | ||
# OR = para ser True apenas um tem que ser True | ||
|
||
print(True and True and True) | ||
print(True and False and True) | ||
print(False and False and False) | ||
print(True or True or True) | ||
print(True or False or False) | ||
print(False or False or False) | ||
|
||
saldo = 1000 | ||
saque = 250 | ||
limite = 200 | ||
conta_especial = True | ||
|
||
exp = saldo >= saque and saque <= limite or conta_especial and saldo >= saque | ||
print(exp) | ||
|
||
exp_2 = (saldo >= saque and saque <= limite) or (conta_especial and saldo >= saque) | ||
print(exp_2) | ||
|
||
conta_normal_com_saldo_suficiente = saldo >= saque and saque <= limite | ||
conta_especial_com_saldo_suficiente = conta_especial and saldo >= saque | ||
|
||
exp_3 = conta_normal_com_saldo_suficiente or conta_especial_com_saldo_suficiente | ||
print(exp_3) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
print("Oi, seja bem vindo ao curso de Python!") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
nome = input("Informe o seu nome: ") | ||
idade = input("Informe a sua idade: ") | ||
|
||
print(nome, idade) | ||
print(nome, idade, end="...\n") | ||
print(nome, idade, sep="#", end="...\n") | ||
print(nome, idade, sep="#") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
nome = "gUIlherME" | ||
|
||
print(nome.upper()) | ||
print(nome.lower()) | ||
print(nome.title()) | ||
|
||
texto = " Olá mundo! " | ||
|
||
print(texto + ".") | ||
print(texto.strip() + ".") | ||
print(texto.rstrip() + ".") | ||
print(texto.lstrip() + ".") | ||
|
||
menu = "Python" | ||
|
||
print("####" + menu + "####") | ||
print(menu.center(14)) | ||
print(menu.center(14, "#")) | ||
print("-".join(menu)) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
nome = "Guilherme" | ||
idade = 28 | ||
profissao = "Progamador" | ||
linguagem = "Python" | ||
saldo = 45.435 | ||
|
||
dados = {"nome": "Guilherme", "idade": 28} | ||
|
||
print("Nome: %s Idade: %d" % (nome, idade)) | ||
|
||
print("Nome: {} Idade: {}".format(nome, idade)) | ||
|
||
print("Nome: {1} Idade: {0}".format(idade, nome)) | ||
print("Nome: {1} Idade: {0} Nome: {1} {1}".format(idade, nome)) | ||
|
||
print("Nome: {nome} Idade: {idade}".format(nome=nome, idade=idade)) | ||
print("Nome: {name} Idade: {age} {name} {name} {age}".format(age=idade, name=nome)) | ||
print("Nome: {nome} Idade: {idade}".format(**dados)) | ||
|
||
print(f"Nome: {nome} Idade: {idade}") | ||
print(f"Nome: {nome} Idade: {idade} Saldo: {saldo:.2f}") | ||
print(f"Nome: {nome} Idade: {idade} Saldo: {saldo:10.1f}") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
nome = "Guilherme Arthur de Carvalho" | ||
|
||
print(nome[0]) | ||
print(nome[-2]) | ||
print(nome[:9]) | ||
print(nome[10:]) | ||
print(nome[10:16]) | ||
print(nome[10:16:2]) | ||
print(nome[:]) | ||
print(nome[::-1]) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
nome = "Guilherme" | ||
|
||
mensagem = f""" | ||
Olá meu nome é {nome}, | ||
Eu estou aprendendo Python. | ||
Essa mensagem tem diferentes recuos. | ||
""" | ||
|
||
print(mensagem) | ||
|
||
|
||
print( | ||
""" | ||
============= MENU ============= | ||
1 - Depositar | ||
2 - Sacar | ||
0 - Sair | ||
================================ | ||
Obrigado por usar nosso sistema!!!! | ||
""" | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
print(11 + 10 + 1000) | ||
print(1.5 + 1 + 0.5) | ||
print(True) | ||
print(False) | ||
print("Python") |
Oops, something went wrong.