generated from reprograma/onX-sx-temaX
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
S04 - Exercícios Larissa #19
Open
larissalemos
wants to merge
1
commit into
reprograma:main
Choose a base branch
from
larissalemos:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,36 @@ | ||
#Desenvolva um programa que faça a tabuada de um número qualquer inteiro que será digitado pelo usuário, mas a tabuada não deve necessariamente | ||
#iniciar em 1 e terminar em 10, o valor inicial e final devem ser informados também pelo usuário, conforme exemplo abaixo: | ||
#Montar a tabuada de: 5 | ||
#Começar por: 4 | ||
#Terminar em: 7 | ||
#Vou montar a tabuada de 5 começando em 4 e terminando em 7: | ||
#5 X 4 = 20 | ||
#5 X 5 = 25 | ||
#5 X 6 = 30 | ||
#5 X 7 = 35 | ||
#Obs: Você deve verificar se o usuário não digitou o final menor que o inicial. | ||
|
||
#opção de como fazer com while: | ||
#while inicial <= final: | ||
#resultado = num * inicial | ||
# print(f"{num} X {inicial} = {resultado}") | ||
#inicial += 1 | ||
|
||
while True: | ||
try: | ||
num = int(input("Você deseja fazer a tabuada de qual número inteiro? ")) | ||
inicial = int(input("Qual é o número inicial da tabuada? ")) | ||
final = int(input("Qual é o número final da tabuada? ")) | ||
|
||
if num >= 0 and num <= 10 and inicial >= 0 and inicial <= 10 and final >= 0 and final <= 10 and final > inicial: | ||
for i in range(inicial, final + 1): | ||
resultado = num * i | ||
print(f"{num} X {i} = {resultado}") | ||
else: | ||
print("Número final deve ser maior que o número inicial") | ||
else: | ||
print("Números devem ser inteiros positivos menores que 10") | ||
|
||
except: | ||
print("Entradas devem ser números inteiros.") | ||
break |
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 @@ | ||
#Faça um Programa que leia 20 números inteiros e armazene-os num vetor. Armazene os números pares no vetor PAR | ||
#e os números IMPARES no vetor impar. Imprima os três vetores. | ||
|
||
lista = [] | ||
lista_par = [] | ||
lista_impar = [] | ||
|
||
while True: | ||
try: | ||
if len(lista) != 20: | ||
numero = int(input("Adicione um número positivo e inteiro à lista: ")) | ||
if numero > 0: | ||
lista.append(numero) | ||
else: | ||
print("Número deve ser inteiro e positivo!") | ||
continue | ||
else: | ||
break | ||
except: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mandou muito bem no try except! |
||
print("Números devem ser inteiros e positivos!") | ||
|
||
|
||
for num in lista: | ||
if (num % 2) == 0: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pode usar somente o |
||
lista_par.append(num) | ||
else: | ||
lista_impar.append(num) | ||
|
||
print(f"Os números pares são: {lista_par}\nOs números ímpares são: {lista_impar}") |
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 @@ | ||
#Supondo que a população de um país A seja da ordem de 80000 habitantes com uma taxa anual de crescimento de 3% e que a população de B seja | ||
#200000 habitantes com uma taxa de crescimento de 1.5%. Faça um programa que calcule e escreva o número de anos necessários para que a | ||
#população do país A ultrapasse ou iguale a população do país B, mantidas as taxas de crescimento. | ||
#Altere o programa anterior permitindo ao usuário informar as populações e as taxas de crescimento iniciais. Valide a entrada e permita | ||
#repetir a operação. | ||
|
||
try: | ||
pop_a = int(input("Qual o número de habitantes do país A? ")) | ||
pop_b = int(input("Qual o número de habitantes do país B? ")) | ||
tx_a = float(input("Qual a taxa de crescimento do país A, em %? Informe apenas o número. ")) / 100 | ||
tx_b = float(input("Qual a taxa de crescimento do país B, em %? Informe apenas o número. ")) / 100 | ||
anos = 0 | ||
|
||
def calc_nova_pop(pop, tx): | ||
nova_pop = pop * (1 + tx) | ||
return nova_pop | ||
|
||
if (pop_a <= pop_b and tx_a > tx_b) or (pop_a >= pop_b and tx_a < tx_b): | ||
while pop_a < pop_b: | ||
pop_a = calc_nova_pop(pop_a, tx_a) | ||
pop_b = calc_nova_pop(pop_b, tx_b) | ||
anos += 1 | ||
print(f"A população do país menos populoso vai alcançar ou ultrapassar a população do mais populoso em {anos} anos.") | ||
else: | ||
print("População dos dois países nunca serão iguais.") | ||
|
||
except: | ||
print("Entradas devem ser numéricas") |
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 @@ | ||
#for numero in range(11): | ||
# print(numero) | ||
|
||
#for numero in range(10, -1, -1): | ||
# print(numero) | ||
|
||
#for numero in range(24, 68, 2): | ||
# print(numero) | ||
|
||
#print(sum(range(11))) | ||
|
||
nome = "Larissa Lemos de Souza".replace(" ","") | ||
print(len(nome)) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testou super bem os casos de contorno. Arrasou!