Skip to content

Commit bb3e176

Browse files
committed
updated
1 parent 2baff48 commit bb3e176

File tree

5 files changed

+39
-38
lines changed

5 files changed

+39
-38
lines changed

ex048.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#Faça um programa que calcule a soma entre todos os números que são múltiplos de três e que se encontram no
2-
# intervalo de 1 até 500.
1+
# Make a program that calculates the sum of all numbers that are multiples of three and that are in the
2+
# range from 1 to 500.
33
soma = 0
4-
cont = 0
4+
counter = 0
55
for c in range(1, 501, 2):
66
if c % 3 == 0:
7-
cont = cont + 1
7+
counter = counter + 1
88
soma = soma + c
9-
print('A soma de todos os {} valores solicitados é {}.'.format(cont, soma))
9+
print(f'The sum of all {counter} requested values is {soma}.')

ex049.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# Refaça o DESAFIO 9, mostrando a tabuada de um número que o usuário escolher, só que agora utilizando um laço for.
2-
num = int(input('Digite um número para ver sua tabuada:'))
1+
# Redo CHALLENGE 9, showing the multiplication table of a number that the user chooses, but now using a for loop.
2+
number = int(input('Enter a number to showing the multiplication:'))
33
for c in range (1,11):
4-
print('{} x {:2} = {}.'.format(num, c, num*c))
5-
4+
print(f'{number} x {c:2} = {number * c}.')

ex051.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#Desenvolva um programa que leia o primeiro termo e a razão de uma PA. No final, mostre os 10 primeiros termos
2-
# dessa progressão.
3-
primeiro = int(input('Primeiro termo:'))
4-
razao = int(input('Razão:'))
5-
decimo = primeiro +(10-1) * razao
6-
for c in range(primeiro, decimo + razao, razao):
7-
print('{}'.format(c), end=' -> ')
8-
print('Acabou')
1+
#Develop a program that reads the first term and the ratio of an AP. At the end, show the first 10 terms
2+
# of this progression.
3+
first = int(input('First term:'))
4+
ratio = int(input('Ratio:'))
5+
tenth = first +(10-1) * ratio
6+
for c in range(first,tenth + ratio, ratio):
7+
print(f'{c}', end=' -> ')
8+
print('He finished')

ex052.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
# Faça um programa que leia um número inteiro e diga se ele é ou não um número primo.
2-
num = int(input('Digite um número inteiro:'))
1+
2+
# Write a program that reads an integer and tells whether or not it is a prime number.
3+
number = int(input('Enter a integer number:'))
34
tot = 0
4-
for c in range(1, num, +1):
5-
if num % c == 0:
5+
for c in range(1, number, +1):
6+
if number % c == 0:
67
print('\033[33m', end=' ')
78
tot += 1
89
else:
910
print('\033[31m', end=' ')
10-
print('{}'.format(c), end=' ')
11-
print('\n\033[m O número {} foi divisível {} vezes.'.format(num, tot))
11+
print(f'{c}', end=' ')
12+
print(f'\n\033[m The number {number} was divisible {tot} times.')
1213
if tot == 2:
13-
print('E por isso ele é primo.')
14+
print('And that is why he is a prime number.')
1415
else:
15-
print('E por isso ele não é primo.')
16+
print('And that is why it is not a prime number.')

ex053.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
# Crie um programa que leia uma frase qualquer e diga se ela é um palíndromo, desconsiderando os espaços. Exemplos de
2-
# palíndromos:
3-
# APÓS A SOPA, A SACADA DA CASA, A TORRE DA DERROTA, O LOBO AMA O BOLO, ANOTARAM A DATA DA MARATONA.
4-
frase = str(input('Digite uma frase:')).strip().upper()
5-
palavras = frase.split()
6-
junto = ''.join(palavras)
7-
inverso = ''
8-
for letra in range(len(junto)-1, -1, -1):
9-
inverso += junto[letra]
10-
print('O inverso de {} é {].'.format(junto, inverso))
11-
if inverso == junto:
12-
print('Temos um palindromo.')
1+
# Create a program that reads any sentence and says if it is a palindrome, disregarding spaces. Examples of
2+
# palindromes:
3+
# AFTER THE SOUP, THE BALCONY OF THE HOUSE, THE TOWER OF DEFEAT, THE WOLF LOVES THE CAKE, THEY WROTE DOWN THE DATE
4+
# OF THE MARATHON.
5+
sentence = str(input('Enter a sentence:')).strip().upper()
6+
words = sentence.split()
7+
together = ''.join(words)
8+
reverse = ''
9+
for words in range(len(together)-1, -1, -1):
10+
reverse += together[words]
11+
print(f'The reverse of {together} is {reverse}.')
12+
if reverse == together:
13+
print('We have a palindrome.')
1314
else:
14-
print('A frase digitada não é um palindromo.')
15+
print('The sentence is not a palindrome.')

0 commit comments

Comments
 (0)