Skip to content

Commit

Permalink
Exercício 110.
Browse files Browse the repository at this point in the history
  • Loading branch information
gguilherme42 committed Mar 13, 2020
1 parent af0ca27 commit 1d1a21b
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 14 deletions.
12 changes: 6 additions & 6 deletions ex107/moeda.py → ex107/moeda0.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'''
Exercício 107:
Crie um módulo chamado moeda.py que tenha as funções aumentar(),
Crie um módulo chamado moeda0.py que tenha as funções aumentar(),
diminuir(), dobro() e metade(). Faça também um programa que importe
este módulo e algumas funções.
'''

def aumentar(n, a):
def aumentar(n=0, a=0):
c = (n * a) / 100
l = c + n
return f'R${l:.2f}'
return l


def diminuir(n, a):
def diminuir(n=0, a=0):
c = (n * a) / 100
l = n - c
return f'R${l:.2f}'
Expand All @@ -22,9 +22,9 @@ def dobro(n):
return f'R${d:.2f}'


def metade(n):
def metade(n=0):
m = n / 2
return f'R${m:.2f}'
return m



6 changes: 6 additions & 0 deletions ex107/test107.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from ex107 import moeda0
n = float(input('Digite um preço: R$'))
print(f'{n} com aumento de 10% é igual a {moeda0.aumentar(n, 10)}')
print(f'{n} menos 10% é igual a {moeda0.diminuir(n, 10)}')
print(f'O dobro de {n} é igual a {moeda0.dobro(n)}')
print(f'A metade de {n} é igual a {moeda0.metade(n)}')
File renamed without changes.
7 changes: 0 additions & 7 deletions ex108/test.py

This file was deleted.

7 changes: 7 additions & 0 deletions ex108/test108.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from ex108 import moeda1
n = float(input('Digite um preço: R$'))
print(moeda1.moeda(n))
print(f'{n} com aumento de 10% é igual a {moeda1.moeda(moeda1.aumentar(n, 10))}')
print(f'{n} menos 10% é igual a {moeda1.moeda(moeda1.diminuir(n, 10))}')
print(f'O dobro de {n} é igual a {moeda1.moeda(moeda1.dobro(n))}')
print(f'A metade de {n} é igual a {moeda1.moeda(moeda1.metade(n))}')
46 changes: 46 additions & 0 deletions ex109/moeda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'''
Exercício 109:
'''


def moeda(n=0, moeda='R$'):
return f'{moeda}{n:.2f}'.replace('.', ',')


def aumentar(n=0, a=0, f=True):
c = (n * a) / 100
l = c + n
if not f:
return l
else:
return moeda(l)


def diminuir(n=0, a=0, f=True):
c = (n * a) / 100
l = n - c
if not f:
return l
else:
return moeda(l)


def dobro(n=0, f=True):
d = n * 2
if not f:
return d
else:
return moeda(d)



def metade(n=0, f=True):
m = n / 2
if not f:
return m
else:
return moeda(m)




3 changes: 2 additions & 1 deletion ex107/test.py → ex109/test109.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ex107 import moeda
from ex109 import moeda
n = float(input('Digite um preço: R$'))
print(moeda.aumentar(n, 10, f=False))
print(f'{n} com aumento de 10% é igual a {moeda.aumentar(n, 10)}')
print(f'{n} menos 10% é igual a {moeda.diminuir(n, 10)}')
print(f'O dobro de {n} é igual a {moeda.dobro(n)}')
Expand Down
59 changes: 59 additions & 0 deletions ex110/moeda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
'''
Exercício 110:
Adicione ao módulo moeda.py criado nos desafios anteriores,
uma função chamada resumo(), que mostre na tela algumas informações
geradas pela funções que já temos no módulo criado até aqui.
'''



def moeda(n=0, moeda='R$'):
return f'{moeda}{n:.2f}'.replace('.', ',')


def aumentar(n=0, a=0, f=True):
c = (n * a) / 100
l = c + n
if not f:
return l
else:
return moeda(l)


def diminuir(n=0, a=0, f=True):
c = (n * a) / 100
l = n - c
if not f:
return l
else:
return moeda(l)


def dobro(n=0, f=True):
d = n * 2
if not f:
return d
else:
return moeda(d)



def metade(n=0, f=True):
m = n / 2
if not f:
return m
else:
return moeda(m)


def resumo(n, a):
print('=' * 30)
print(f' {"RESUMO":^30} ')
print('-' * 30)
print(f'{"- Aumento: ":<5} {aumentar(n, a):>10}')
print(f'{"- Diminuição: ":<5} {diminuir(n, a):>10}')
print(f'{"- Dobro: ":<5} {dobro(n):>10}')
print(f'{"- Metade: ":<5} {metade(n):>10}')
print('=' * 30)


8 changes: 8 additions & 0 deletions ex110/test110.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from ex110 import moeda
n = float(input('Digite um preço: R$'))
print(moeda.aumentar(n, 10, f=False))
print(f'{n} com aumento de 10% é igual a {moeda.aumentar(n, 10)}')
print(f'{n} menos 10% é igual a {moeda.diminuir(n, 10)}')
print(f'O dobro de {n} é igual a {moeda.dobro(n)}')
print(f'A metade de {n} é igual a {moeda.metade(n)}')
moeda.resumo(n, 10)

0 comments on commit 1d1a21b

Please sign in to comment.