-
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.
- Loading branch information
Magda Rocha
committed
Oct 27, 2023
1 parent
e1213a9
commit 9a4661d
Showing
4 changed files
with
133 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,34 @@ | ||
#Ler a idade e sexo de várias pessoas. A cada pessoa inscrita o programa deve perguntar se o utilizador quer ou não continuar. | ||
#No final mostrar: quantas pessoas têm mais de 18 anos, quantos homens estão inscritos e quantas mulheres têm menos de 20 anos | ||
|
||
contagem_18anos = 0 | ||
|
||
contagem_homens = 0 | ||
|
||
contagem_mulheres_menos20anos = 0 | ||
|
||
|
||
while True: | ||
idade = int(input(' Que idade tens? ')) | ||
sexo = str(input(' Qual é o teu sexo? ')).upper() | ||
|
||
continuar = input((' Quer continuar? [S,N] ')).upper() | ||
|
||
|
||
if idade > 18: | ||
contagem_18anos += 1 | ||
|
||
if sexo == 'M': | ||
contagem_homens += 1 | ||
|
||
if sexo == 'F': | ||
if idade < 20: | ||
contagem_mulheres_menos20anos += 1 | ||
|
||
|
||
if continuar == 'N': | ||
break | ||
|
||
print( f'{contagem_18anos} têm mais que 18 anos! Estão inscritos {contagem_homens} homens! {contagem_mulheres_menos20anos} são mulheres e têm menos de 20 anos! ') | ||
|
||
|
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,33 @@ | ||
#Ler o nome e preço de vários produtos | ||
#Perguntar se quer continuar | ||
# Qual o total gasto na compra | ||
#Quantos produtos custam mais de 1000€ | ||
# Qual é o nome do produto mais barato | ||
|
||
soma = 0 | ||
contagem = 0 | ||
mais_barato = 9999 | ||
nome_mais_barato = '' | ||
|
||
while True: | ||
nome = str(input(' Escreve o nome de um produto: ' )) | ||
preco = float(input(' Qual é o preço: ')) | ||
continuar = input((' Quer continuar?[S/N]')).upper() | ||
|
||
soma = soma + preco | ||
|
||
if preco > 1000: | ||
contagem += 1 | ||
|
||
if preco < mais_barato: | ||
mais_barato = preco | ||
nome_mais_barato = nome | ||
|
||
if continuar == 'N': | ||
break | ||
|
||
|
||
|
||
|
||
|
||
print(f' A soma dos produtos é {soma}. {contagem} produtos custam mais de 1000€. O mais barato é {nome_mais_barato} ') |
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,28 @@ | ||
# Simular um ATM | ||
# Perguntar o valor a levantar | ||
#O programa deve informar quantas notas de cada vão ser levantadas | ||
#Só existem notas de 50 , 20, 10 e 1 | ||
|
||
notas_50 = 0 | ||
notas_20 = 0 | ||
notas_10 = 0 | ||
notas_1 = 0 | ||
|
||
|
||
valor = int(input(' Quanto quer levantar? ')) | ||
|
||
while valor != 0: | ||
if valor >= 50: | ||
notas_50 += 1 | ||
valor = valor - 50 | ||
elif valor >= 20: | ||
notas_20 += 1 | ||
valor = valor - 20 | ||
elif valor >= 10: | ||
notas_10 += 1 | ||
valor = valor - 10 | ||
elif valor >= 1: | ||
notas_1 += 1 | ||
valor = valor - 1 | ||
|
||
print(f' Vão-lhe ser dadas {notas_50} notas de 50, {notas_20} notas de 20, {notas_10} notas de 10 e {notas_1} notas de 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,38 @@ | ||
class Animais: | ||
|
||
def __init__(self, nome, especie, cor, altura, peso, idade): | ||
|
||
self.nome = nome | ||
|
||
self.especie = especie | ||
|
||
self.altura = altura | ||
|
||
self.peso = peso | ||
|
||
self.idade = idade | ||
|
||
self.cor = cor | ||
|
||
def comer(self, comida): | ||
|
||
self.peso += comida | ||
|
||
return print(f' O animal de nome {self.nome}, da espécie {self.especie}, com a cor {self.cor}, com a altura {self.altura}, comeu e ficou com o peso de {self.peso} kg. Tem a idade de {self.idade} anos.') | ||
|
||
|
||
def soma(n1, n2): | ||
s = n1 + n2 | ||
print(s) | ||
return s | ||
|
||
gato = Animais('Snow', 'europeu comum','branco', '50 cm', 5, 7 ) | ||
|
||
gato.comer(1) | ||
|
||
|
||
len([1, 2]) | ||
|
||
resultado = soma(1, 2) | ||
|
||
resultado = resultado +2 |