Skip to content

Commit 6fdc54b

Browse files
committed
Refeitos os exercicios 107, 108, 109, 110 iniciado
1 parent 429f346 commit 6fdc54b

File tree

11 files changed

+188
-2
lines changed

11 files changed

+188
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/__pycache__

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -293,4 +293,9 @@ The user will type the command and the manual will appear.
293293
When the user enters the word 'END', the program will terminate.
294294
NOTE: Use colors.'
295295
### Modules and Packeges:
296-
* Ex107: '
296+
* Ex107: 'Create a module called currency.py that has built-in functions increase(), decrease(), double(), half().
297+
Also make a program that imports this module and uses some of these functions.'
298+
* Ex108: 'Adapt the code from challenge 107 by creating an additional function called currency() that can display the values as a formatted currency value.'
299+
* Ex109: 'Modify the function created in challenge 107 so that they accept one more parameter, informing wheter or not the value returned by them will be the currency() function, developed in challenge 108.'
300+
* Ex110: 'Add to the currency.py module created in the precious challenges, a function called summary(), which shows on the screen some information generated by the functions we already have in the module created so far.'
301+
* Ex111: '

README_ptbr.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -292,4 +292,9 @@ O usuário vai digitar o comando e o manual vai aparecer.
292292
Quando o usuário digitar a palavra 'FIM', o programa se encerrará.
293293
OBS: Use cores.'
294294
### Módulos e Pacotes:
295-
* Ex107: '
295+
* Ex107: 'Crie um módulo chamado moeda.py que tenha as funções incorporadas aumentar(), diminuir(), dobro(), metade().
296+
Faça também um programa que importe esse módulo e use algumas dessas funções.'
297+
* Ex108: 'Adapte o código do desafio 107, criando uma função adicional chamada moeda() que consiga mostrar os valores como um valor monetário formatado.'
298+
* Ex109: 'Modifique as funções criadas no desafio 107 para que elas aceitem um parâmetro a mais, informando se o valor retornado por elas vai ser ou não formatado pela função moeda(), desenvolvido no desafio 108.'
299+
* Ex110: 'Adicione ao módulo moeda.py criado nos desafios anteriores, uma função chamada resumo(), que mostre na tela algumas informações geradas pelas funções que já temos no módulo criado até aqui.'
300+
* Ex111: '
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
def half(value):
2+
result = value / 2
3+
return result
4+
5+
6+
def double(value):
7+
result = value * 2
8+
return result
9+
10+
11+
def increase(value, porcentage):
12+
increase = value * porcentage / 100
13+
result = value + increase
14+
return result
15+
16+
17+
def decrease(value, porcentage):
18+
increase = value * porcentage / 100
19+
result = value - increase
20+
return result

reworked exercices/ex107.2/ex107.2.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Ex107.2
2+
"""Create a module called currency.py that has built-in functions increase(), decrease(), double(), half().
3+
Also make a program that imports this module and uses some of these functions."""
4+
5+
import currency
6+
7+
print("\033[34m==\033[m" * 20)
8+
price = float(input('Enter a price: '))
9+
print(f'\033[31mThe half of \033[32m{price:.2f}\033[31m is \033[32m{currency.half(price):.2f}\033[m')
10+
print(f'\033[33mThe double of \033[32m{price:.2f}\033[33m is \033[32m{currency.double(price):.2f}\033[m')
11+
print(f'\033[34mIncrease 10% we have \033[32m{currency.increase(price, 10):.2f}\033[m')
12+
print(f'\033[35mDecreasing 10% we have \033[32m{currency.decrease(price, 10):.2f}\033[m')
13+
print("\033[34m==\033[m" * 20)
14+
print('xD')
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
def half(value):
2+
result = value / 2
3+
return result
4+
5+
6+
def double(value):
7+
result = value * 2
8+
return result
9+
10+
11+
def increase(value, porcentage):
12+
increase = value * porcentage / 100
13+
result = value + increase
14+
return result
15+
16+
17+
def decrease(value, porcentage):
18+
increase = value * porcentage / 100
19+
result = value - increase
20+
return result
21+
22+
23+
def currency(value):
24+
result = f'RS: {value:.2f}'
25+
result.replace('.', ',')
26+
return result

reworked exercices/ex108.2/ex108.2.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Ex108.2
2+
"""Adapt the code from challenge 107 by creating an additional function called currency() that can display the values as a formatted currency value."""
3+
4+
import currency
5+
6+
print("\033[34m==\033[m" * 20)
7+
price = float(input('Enter a price: '))
8+
print(f'\033[31mThe half of \033[32m{currency.currency(price)}\033[31m is \033[32m{currency.currency(currency.half(price))}\033[m')
9+
print(f'\033[33mThe double of \033[32m{currency.currency(price)}\033[33m is \033[32m{currency.currency(currency.double(price))}\033[m')
10+
print(f'\033[34mIncrease 10% we have \033[32m{currency.currency(currency.increase(price, 10))}\033[m')
11+
print(f'\033[35mDecreasing 10% we have \033[32m{currency.currency(currency.decrease(price, 10))}\033[m')
12+
print("\033[34m==\033[m" * 20)
13+
print('xD')
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
def half(value, monetary=False):
2+
result = value / 2
3+
if monetary:
4+
return currency(result)
5+
else:
6+
return result
7+
8+
9+
def double(value, monetary=False):
10+
result = value * 2
11+
if monetary:
12+
return currency(result)
13+
else:
14+
return result
15+
16+
17+
def increase(value, porcentage, monetary=False):
18+
increase = value * porcentage / 100
19+
result = value + increase
20+
if monetary:
21+
return currency(result)
22+
else:
23+
return result
24+
25+
26+
def decrease(value, porcentage, monetary=False):
27+
increase = value * porcentage / 100
28+
result = value - increase
29+
if monetary:
30+
return currency(result)
31+
else:
32+
return result
33+
34+
35+
def currency(value):
36+
result = f'RS: {value:.2f}'
37+
result.replace('.', ',')
38+
return result

reworked exercices/ex109.2/ex109.2.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Ex109.2
2+
"""Modify the function created in challenge 107 so that they accept one more parameter, informing wheter or not the value returned by them will be the currency() function, developed in challenge 108."""
3+
4+
import currency
5+
6+
print("\033[34m==\033[m" * 20)
7+
price = float(input('Enter a price: '))
8+
print(f'\033[31mThe half of \033[32m{currency.currency(price)}\033[31m is \033[32m{(currency.half(price, True))}\033[m')
9+
print(f'\033[33mThe double of \033[32m{currency.currency(price)}\033[33m is \033[32m{currency.double(price, True)}\033[m')
10+
print(f'\033[34mIncrease 10% we have \033[32m{currency.increase(price, 10, True)}\033[m')
11+
print(f'\033[35mDecreasing 10% we have \033[32m{currency.decrease(price, 10, True)}\033[m')
12+
print("\033[34m==\033[m" * 20)
13+
print('xD')
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
def half(value, monetary=False):
2+
result = value / 2
3+
if monetary:
4+
return currency(result)
5+
else:
6+
return result
7+
8+
9+
def double(value, monetary=False):
10+
result = value * 2
11+
if monetary:
12+
return currency(result)
13+
else:
14+
return result
15+
16+
17+
def increase(value, porcentage, monetary=False):
18+
increase = value * porcentage / 100
19+
result = value + increase
20+
if monetary:
21+
return currency(result)
22+
else:
23+
return result
24+
25+
26+
def decrease(value, porcentage, monetary=False):
27+
increase = value * porcentage / 100
28+
result = value - increase
29+
if monetary:
30+
return currency(result)
31+
else:
32+
return result
33+
34+
35+
def currency(value):
36+
result = f'RS: {value:.2f}'
37+
result.replace('.', ',')
38+
return result

reworked exercices/ex110.2/ex110.2.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Ex110.2
2+
"""Add to the currency.py module created in the precious challenges, a function called summary(), which shows on the screen some information generated by the functions we already have in the module created so far."""
3+
4+
import currency
5+
6+
print("\033[34m==\033[m" * 20)
7+
price = float(input('Enter a price: '))
8+
print(f'\033[31mThe half of \033[32m{currency.currency(price)}\033[31m is \033[32m{(currency.half(price, True))}\033[m')
9+
print(f'\033[33mThe double of \033[32m{currency.currency(price)}\033[33m is \033[32m{currency.double(price, True)}\033[m')
10+
print(f'\033[34mIncrease 10% we have \033[32m{currency.increase(price, 10, True)}\033[m')
11+
print(f'\033[35mDecreasing 10% we have \033[32m{currency.decrease(price, 10, True)}\033[m')
12+
print("\033[34m==\033[m" * 20)
13+
print('xD')

0 commit comments

Comments
 (0)