-
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 21, 2023
1 parent
1b72bda
commit ed02441
Showing
12 changed files
with
140 additions
and
1 deletion.
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
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,8 @@ | ||
# Mostrar uma contagem regressiva para o estourar de fogos de artifico andando de 10 até 0 com uma pausa de 1 segundo entre eles. | ||
|
||
import time | ||
|
||
for i in range(10 , -1, -1): | ||
print(i) | ||
time.sleep(1) | ||
print(' PUM PUM PUM') |
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 @@ | ||
#Mostrar todos os números pares que estão no intervalo entre 1 e 50 | ||
|
||
for i in range(1,51): | ||
resto = i%2 | ||
if resto == 0: | ||
print(i) |
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 @@ | ||
#Soma entre todos os números impares que são múltiplos de 3 e que se encontram no intervalo de 1 ate 500 | ||
|
||
soma=0 | ||
for i in range(1,501): | ||
resto = i%2 | ||
if resto == 1: | ||
multiplo = i%3 | ||
if multiplo == 0: | ||
soma = soma + i | ||
|
||
print(soma) |
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,8 @@ | ||
#Refazer o exercício 9 com a função for | ||
#Ler um número inteiro e mostrar a sua tabuada | ||
|
||
numero = int(input(' Escreve um número: ')) | ||
|
||
for i in range( 1, 11): | ||
tabuada = numero * i | ||
print('{} x {} = {}'.format( numero, i , tabuada)) |
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,8 @@ | ||
#Ler 6 números inteiro e mostrar a soma daqueles que forem pares. Se o valor for impar desconsiderar. | ||
|
||
soma = 0 | ||
for i in range(1,7): | ||
numero = int(input(' Escreva um número ')) | ||
if numero%2 == 0: | ||
soma = soma + numero | ||
print (soma) |
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 @@ | ||
#Ler o primeiro termo e a razão de uma progressão aritmética | ||
# No final mostrar os 10 primeiros termos dessa progressão | ||
|
||
termo = int(input(' Diga-me o primeiro termo da PA ')) | ||
razao = int(input(' Diga-me a razão da PA ')) | ||
|
||
soma = termo | ||
for i in range(1 , 11): | ||
soma = soma + razao | ||
print(soma) |
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,14 @@ | ||
#Ler um numero inteiro e dizer se é ou não primo | ||
|
||
numero = int(input(' Digite um número: ')) | ||
contagem = 0 | ||
for i in range( 1 , numero+1): | ||
resto = numero%i | ||
if resto == 0: | ||
contagem = contagem + 1 | ||
|
||
if contagem <= 2: | ||
print(' é um número primo ') | ||
|
||
else: | ||
print (' não é um número primo ') |
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,13 @@ | ||
#Ler uma frase qualquer e dizer se é um palíndromo, desconsiderando os espaços. | ||
|
||
frase = str(input(' Escreva uma frase ')) | ||
|
||
semespaco = frase.replace(' ' , '') | ||
semespaco = semespaco.upper() | ||
|
||
aocontrario = "" | ||
for i in range(len(semespaco)-1, -1, -1): | ||
aocontrario = aocontrario + semespaco[i] | ||
print(aocontrario) | ||
if semespaco == aocontrario: | ||
print(' É polindromo') |
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 @@ | ||
#Ler o ano de de nascimento de sete pessoas. No final mostrar quantas pessoas ainda não atingiram a maioridade e quantas já são maiores | ||
menores = 0 | ||
maiores = 0 | ||
|
||
for i in range(1,8): | ||
ano = int(input(' Escreva o seu ano de nascimento? ')) | ||
idade = 2023 - ano | ||
if idade < 18: | ||
menores = menores + 1 | ||
elif idade >= 18: | ||
maiores = maiores + 1 | ||
print(' {} pessoas ainda não atingiram a maioridade, {} pessoas já atingiram'.format( menores , maiores)) |
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 @@ | ||
#Ler o pesos de cinco pessoas. Mostrar qual foi o maior e o menor peso lido. | ||
|
||
maior = 0 | ||
menor = 200 | ||
|
||
|
||
for i in range(1, 6): | ||
peso = float(input(' Escreve o teu peso: ')) | ||
if peso > maior: | ||
maior = peso | ||
|
||
if peso < menor: | ||
menor = peso | ||
|
||
print(' O peso maior é {}, o peso menor é {}: '.format(maior , menor)) |
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, idade e sexo de 4 pessoas | ||
# Mostrar a média de idade do grupo | ||
# O nome do homem mais velhor | ||
# Quantas mulheres têm menos de 20 anos | ||
idades = 0 | ||
idade_mais_velha = 0 | ||
nome_do_mais_velho = '' | ||
contagem_mulheres_abaixo_vinte = 0 | ||
|
||
for i in range(1,5): | ||
nome = str(input(' Escreve o teu nome: ')) | ||
idade = int(input(' Diz-me a tua idade: ')) | ||
sexo = str(input(' Qual é o teu sexo?: ')) | ||
|
||
idades = idade + idades | ||
if sexo == 'masculino': | ||
if idade > idade_mais_velha: | ||
idade_mais_velha = idade | ||
nome_do_mais_velho = nome | ||
|
||
if sexo == 'feminino': | ||
if idade < 20: | ||
contagem_mulheres_abaixo_vinte = contagem_mulheres_abaixo_vinte + 1 | ||
|
||
|
||
media = idades/4 | ||
|
||
print( ' A média de idade do grupo é {} '.format(media)) | ||
|
||
print(' O nome do homem mais velho é {} '.format (nome_do_mais_velho)) | ||
|
||
print(' O número de mulheres com menos de 20 anos é {}'.format(contagem_mulheres_abaixo_vinte)) | ||
|