Skip to content

Commit 063aace

Browse files
committed
doc: add comments
loop structure : for. Sum of add multiples of three.
1 parent 79ddff5 commit 063aace

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ex048.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#Sum of odd multiples of three
12
#48- Make a program that calculates the sum of all numbers that are multiples of three and that are in the
23
# range from 1 to 500.
34
soma = 0
@@ -7,3 +8,18 @@
78
counter = counter + 1
89
soma = soma + c
910
print(f'The sum of all {counter} requested values is {soma}.')
11+
12+
13+
#Soma ímpares múltiplos de três
14+
# 48: 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
15+
# intervalo de 1 até 500.
16+
soma = contador = 0
17+
for c in range(1,501,2):
18+
if c % 3 == 0:
19+
contador = contador + 1
20+
soma = soma + c
21+
print(f'Ao todo existem {contador} números multiplos de 3 em um intervalo de 1 a 500 e sua soma é {soma}.')
22+
23+
24+
#PT- Estruturas de repetições: For.
25+
#EN- Loop structures: For.

0 commit comments

Comments
 (0)