-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Novos desafios condiçoes if else e elif
- Loading branch information
Magda Rocha
committed
Oct 21, 2023
1 parent
086f2b2
commit 1b72bda
Showing
7 changed files
with
141 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,6 @@ | ||
#Refazer o desafio 35 e acrescentar o recurso de mostrar que tipo de triângulo será formado: | ||
#Equilátero com todos os lados iguais | ||
#Isósceles com dois lados iguais | ||
#Escaleno com todos os lados diferentes | ||
|
||
#TODO Depois de fazer o 35 |
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 @@ | ||
#Ler o ano de nascimento de um jovem e informar de acordo com a idade: | ||
#Se ele ainda se vai alistar ao serviço militar | ||
#Se é a hora de se alistar | ||
#Se já passou do tempo de alistar | ||
#Também deve mostrar o tempo que falta ou que passou do prazo | ||
|
||
ano = int(input(' Qual o teu ano de nascimento? ')) | ||
idade = 2023 - ano | ||
|
||
if 18 <= idade < 21: | ||
print (' Ainda te podes alistar ') | ||
prazo = 21 - idade | ||
print (' Ainda tens {} anos '.format (prazo)) | ||
elif idade == 21: | ||
print ( ' Está na hora de te alistares') | ||
elif idade > 21: | ||
print (' Já não te podes alistar ') | ||
prazo1 = idade - 21 | ||
print(' Passaram {} anos depois do prazo. '.format( prazo1)) | ||
else: | ||
print (' És menor de idade. Não te podes alistar') | ||
|
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 @@ | ||
#Ler duas notas de um aluno e calcular a média | ||
# Mostrar uma mensagem no final de acordo com a média atingida: | ||
#Média abaixo de 5.0 Reprovado | ||
#Média entre 5.0 e 6.9: Recuperação | ||
# Média 7.0 ou superior: Aprovado | ||
|
||
nota = float(input( ' Qual foi a tua nota? ')) | ||
nota1 = float(input( ' Qual foi a tua segunda nota? ')) | ||
media = float(nota+nota1) / 2 | ||
|
||
if media <= 5.0: | ||
print (' Reprovado ') | ||
elif 5.0 < media <= 6.9: | ||
print (' Recuperação ') | ||
elif media >= 7.0: | ||
print (' Aprovado ') |
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,21 @@ | ||
#Ler o ano de nascimento de um atleta e mostrar a categoria de acordo com a idade | ||
# Até 9 anos: Mirim | ||
# Até 14 anos: Infantil | ||
# Até 19 anos: Junior | ||
# Até 20 anos: Sénior | ||
# Acima: Master | ||
|
||
ano = int(input(' Qual o teu ano de nascimento? ')) | ||
idade = 2023 - ano | ||
|
||
if idade <= 9: | ||
print ( ' Mirim ') | ||
elif 9 < idade <= 14: | ||
print (' Infantil ') | ||
elif 14 < idade <= 19: | ||
print (' Junior') | ||
elif 19 < idade <= 20: | ||
print (' Sénior') | ||
elif idade > 20: | ||
print (' Master') | ||
|
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,23 @@ | ||
#Ler o peso e a altura de uma pessoa | ||
#Calcular o IMC e mostrar o status de acordo coma tabela | ||
#Abaixo de 18.5: abaixo do peso | ||
#Entre 18.5 e 25: Peso ideal | ||
#Entre 25 e até 30: Sobrepeso | ||
#30 Até 40: Obesidade | ||
#Acima de 40: Obesidade mórbida | ||
|
||
peso = float(input(' Quanto pesas? ')) | ||
altura = float(input(' Quanto medes? ')) | ||
IMC = peso / altura**2 | ||
|
||
if IMC < 18.5: | ||
print(' Abaixo do peso ') | ||
elif 18.5 <= IMC <= 25: | ||
print( ' Peso ideal ') | ||
elif 25 < IMC <= 30: | ||
print(' Sobrepeso ') | ||
elif 30 < IMC <= 40: | ||
print(' Obesidade ') | ||
elif IMC > 40: | ||
print( ' Obesidade Mórbida ') | ||
|
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 @@ | ||
#Calcular o valor a ser pago por um produto considerando o seu preço normal e condição de pagamento: | ||
# Dinheiro/cheque: 10% de desconto | ||
# Cartão:5% de desconto | ||
# 2x no cartão: preço normal | ||
# 3x ou mais no cartão: 20% de juros | ||
|
||
preco = float(input( ' Qual o preço do produto? ')) | ||
condicao = str(input( ' Qual a condição de pagamento? ')) | ||
|
||
if condicao == 'dinheiro' or condicao == 'cheque': | ||
pagamento = preco - (preco * 0.10) | ||
print(' Tens que pagar {} euros'.format(pagamento)) | ||
|
||
elif condicao == 'cartão': | ||
pagamento1 = preco - (preco * 0.05) | ||
print (' Tens que pagar {} euros '.format(pagamento1)) | ||
|
||
elif condicao == '2x': | ||
print( preco ) | ||
|
||
elif condicao == '3x': | ||
pagamento3 = preco + (preco * 0.20) | ||
print (' Tens que pagar {} euros '.format(pagamento3)) | ||
|
||
|
||
|
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,27 @@ | ||
#Fazer o computador jogar o jogo "Pedra papel tesoura" | ||
|
||
|
||
import random | ||
|
||
jogo = str(input(' Escolhe pedra, papel ou tesoura: ')) | ||
|
||
lista = ['pedra' , 'papel' , 'tesoura'] | ||
escolha = random.choice(lista) | ||
|
||
print(' O computador escolheu {}'.format(escolha)) | ||
|
||
if jogo == escolha: | ||
print (' Empatou') | ||
elif jogo == 'pedra' and escolha == 'papel': | ||
print (' Você perdeu') | ||
elif jogo == 'pedra' and escolha == ' tesoura': | ||
print (' Você ganhou') | ||
elif jogo == 'papel' and escolha == 'pedra': | ||
print (' Você ganhou') | ||
elif jogo == 'papel' and escolha == 'tesoura': | ||
print (' Você perdeu') | ||
elif jogo == 'tesoura' and escolha == 'pedra': | ||
print (' Você perdeu') | ||
elif jogo == 'tesoura' and escolha == 'papel': | ||
print ('Você ganhou') | ||
|