Skip to content

Commit b5c4077

Browse files
committed
Terminado o ex 110 e feito o ex 111
1 parent 6fdc54b commit b5c4077

File tree

6 files changed

+80
-8
lines changed

6 files changed

+80
-8
lines changed

README_ptbr.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,4 +297,6 @@ Faça também um programa que importe esse módulo e use algumas dessas funçõe
297297
* 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.'
298298
* 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.'
299299
* 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: '
300+
* Ex111: 'Crie um pacote chamado utilidadesCeV que tenha dois módulos internos chamados moeda e dado.
301+
Transfira todas as fuções utilizadas nos desafios 107, 108 e 109 para o primeiro pacote e mantenha tudo funcionando.'
302+
* Ex112: '

reworked exercices/ex110.2/currency.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,16 @@ def decrease(value, porcentage, monetary=False):
3535
def currency(value):
3636
result = f'RS: {value:.2f}'
3737
result.replace('.', ',')
38-
return result
38+
return result
39+
40+
def summary(value, increases, decreases):
41+
print("\033[34m<>\033[m" * 21)
42+
print(f"{'VALUE SUMMARY':^40}")
43+
print("\033[34m<>\033[m" * 21)
44+
print(f"{'Analysed price:':.<30}\033[32m{currency(value):>10}\033[m")
45+
print(f"{'Double the price:':.<30}\033[32m{double(value, True):>10}\033[m")
46+
print(f"{'Half-price:':.<30}\033[32m{half(value, True):>10}\033[m")
47+
print(f"{f'{increases}% increase':.<30}\033[32m{increase(value, increases, True):>10}\033[m")
48+
print(f"{f'{decreases}% reduction':.<30}\033[32m{decrease(value, decreases, True):>10}\033[m")
49+
print("\033[34m<>\033[m" * 21)
50+

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33

44
import currency
55

6-
print("\033[34m==\033[m" * 20)
6+
print("\033[34m==\033[m" * 21)
77
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)
8+
currency.summary(price, 80, 35)
9+
print("\033[34m==\033[m" * 21)
1310
print('xD')

reworked exercices/ex111.2/ex111.2.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Ex111.2
2+
"""Create a package called utilitiesCeV that has two built-in modules called currency and data.
3+
Transfer all the functions used in challenges 107, 108, 109 to the first package and keep every running."""
4+
5+
from utilitiescev import currency
6+
7+
print("\033[34m==\033[m" * 21)
8+
price = float(input('Enter a price: '))
9+
currency.summary(price, 80, 35)
10+
print("\033[34m==\033[m" * 21)
11+
print('xD')
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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
39+
40+
def summary(value, increases, decreases):
41+
print("\033[34m<>\033[m" * 21)
42+
print(f"{'VALUE SUMMARY':^40}")
43+
print("\033[34m<>\033[m" * 21)
44+
print(f"{'Analysed price:':.<30}\033[32m{currency(value):>10}\033[m")
45+
print(f"{'Double the price:':.<30}\033[32m{double(value, True):>10}\033[m")
46+
print(f"{'Half-price:':.<30}\033[32m{half(value, True):>10}\033[m")
47+
print(f"{f'{increases}% increase':.<30}\033[32m{increase(value, increases, True):>10}\033[m")
48+
print(f"{f'{decreases}% reduction':.<30}\033[32m{decrease(value, decreases, True):>10}\033[m")
49+
print("\033[34m<>\033[m" * 21)
50+

reworked exercices/ex111.2/utilitiescev/data/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)