Skip to content

Commit bcbb472

Browse files
AAL CHALLENGES - FINISHED WITH HELP OF GUANABARA
1 parent 9925ca9 commit bcbb472

File tree

11 files changed

+160
-108
lines changed

11 files changed

+160
-108
lines changed

Código Backup/.idea/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

Código Backup/.idea/Código Backup.iml

Lines changed: 0 additions & 8 deletions
This file was deleted.

Código Backup/.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

Código Backup/.idea/misc.xml

Lines changed: 0 additions & 4 deletions
This file was deleted.

Código Backup/.idea/modules.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

Código Backup/.idea/vcs.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

Mundo-03.py

Lines changed: 77 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
'''for count in range(0, len(lanche)):
99
print(f"Vou comer {lanche[count]} na posição {count}")
1010
print("Comi pra caramba")'''
11-
import random
1211

1312
'''for comida in lanche:
1413
print(f"Vou comer {comida}")
@@ -157,23 +156,23 @@
157156
print(f"The bigger number was {m}")
158157
print(f"The lower number was {n}")'''
159158

160-
# b = str(a)
161-
# tupla1 = str(a)
162-
# del(a)
163-
# d = str(a)
164-
# tupla2 = b + tupla1
165-
# del(b)
166-
# e = str(d)
167-
# tupla3 = e + tupla1 + tupla2
168-
# del(d)
169-
# f = str(e)
170-
# tupla4 = f + tupla1 + tupla2 + tupla3
171-
# del(e)
172-
# g = str(f)
173-
# tupla5 = g + tupla1 + tupla2 + tupla3 + tupla4
174-
# del(f)
175-
# total = list(tupla5)
176-
# print(d)
159+
# b = str(a)
160+
# tupla1 = str(a)
161+
# del(a)
162+
# d = str(a)
163+
# tupla2 = b + tupla1
164+
# del(b)
165+
# e = str(d)
166+
# tupla3 = e + tupla1 + tupla2
167+
# del(d)
168+
# f = str(e)
169+
# tupla4 = f + tupla1 + tupla2 + tupla3
170+
# del(e)
171+
# g = str(f)
172+
# tupla5 = g + tupla1 + tupla2 + tupla3 + tupla4
173+
# del(f)
174+
# total = list(tupla5)
175+
# print(d)
177176

178177
# SOLUTION FROM GUANABARA
179178

@@ -272,9 +271,8 @@
272271
else:
273272
print(f"{listing[pos]:>7.2f}")'''
274273

275-
276274
# CHALLENGE 77
277-
#Crie um programa que tenha uma tupla com várias palavras (não usar acentos).
275+
# Crie um programa que tenha uma tupla com várias palavras (não usar acentos).
278276
# Depois disso, você deve mostrar, para cada palavra, quais são as suas vogais.
279277

280278
'''lotWords = ("rice", "mouse", "notebook", "chair", "tv", "light", "sofa", "plate", "screem", "aleloui")
@@ -398,7 +396,6 @@
398396
print(f"O biggest value entered was {max(valNum)}, in the positions {rankMax}")
399397
print(f"O lowest value entered was {min(valNum)}, in the positions {rankMin}")'''
400398

401-
402399
# ////////////////////////////////////////////////////////
403400

404401
# Done
@@ -493,7 +490,6 @@
493490
if(valueB == lower):
494491
print(f"{pos}", end="...")'''
495492

496-
497493
# CHALLENGE 79
498494
# Crie um programa onde o usuário possa digitar vários valores numéricos e cadastre-os em uma lista.
499495
# Caso o número já exista lá dentro, ele não será adicionado. No final, serão exibidos todos os valores únicos digitados, em ordem crescente.
@@ -603,7 +599,6 @@
603599
print(f"Você cadastrou, em ordem, os números: {lista}")
604600
print(len(lista))'''
605601

606-
607602
# CHALLENGE 81
608603
# Crie um programa que vai ler vários números e colocar em uma lista. Depois disso, mostre:
609604
# A) Quantos números foram digitados. B) A lista de valores, ordenada de forma decrescente. C) Se o valor 5 foi digitado e está ou não na lista.
@@ -863,7 +858,6 @@
863858
if n % 2 != 0:
864859
print(f'{n} ', end='')'''
865860

866-
867861
# for n in numeros:
868862
# # if(n % 2 == 0):
869863
# numeros.append([n[numeros]])
@@ -946,7 +940,6 @@
946940
print(f"[{numero1:^5}]", end=" ")
947941
print()'''
948942

949-
950943
# CHALLENGE 87
951944
# Aprimore o desafio anterior, mostrando no final.
952945
# A) A soma de todos os valores pares digitados. B) A soma dos valores da terceira coluna. C) O maior valor da segunda linha.
@@ -1251,7 +1244,6 @@
12511244
print(" "*3, f"{i+1}º place: {v[0]} with {v[1]}.")
12521245
sleep(1)'''
12531246

1254-
12551247
# print(player)
12561248
# print()
12571249
# playerList = list(player)
@@ -1703,11 +1695,9 @@ def sumpair():
17031695
'''print(help())
17041696
help(print("Olá"))'''
17051697

1706-
17071698
'''print(input.__doc__)
17081699
help(input)'''
17091700

1710-
17111701
# MANUAL OR SIMPLE -> DOCSTRING
17121702

17131703
'''def contador(i, f, p):
@@ -1748,7 +1738,6 @@ def somar(a=0, b=5, c=4): # parameter optional -> value = 0 another value = 1 :
17481738
somar(b=3, c=2)
17491739
help(somar)'''
17501740

1751-
17521741
# SCOPE OF VARIABLES
17531742

17541743
'''def local():
@@ -2061,7 +2050,6 @@ def titulo(msg, cor=0):
20612050
ajuda(comando)
20622051
titulo("ATÉ LOGO!", 1)'''
20632052

2064-
20652053
# CLASS 22
20662054
# MÓDULOS E PACOTES
20672055

@@ -2078,7 +2066,6 @@ def titulo(msg, cor=0):
20782066
print(f"O dobro de {num} é {numeros.dobro(num)}")
20792067
print(f"O triplo de {num} é {numeros.triplo(num)}")'''
20802068

2081-
20822069
# CHALLENGE 107
20832070

20842071
# productValue = float(input("How much is the product ? "))
@@ -2097,25 +2084,78 @@ def titulo(msg, cor=0):
20972084
# print(f" And the value is{a}")
20982085
# print(f"The decrease of 10% of {p} is {diminuir(p, 10):.2f} R$"), # then the value total is{moeda.diminuir(p)}")'''
20992086

2100-
21012087
# CHALLENGE 108
21022088

2103-
'''# def ():
2089+
# def ():
21042090
# from moeda import metade
21052091
# return metade
21062092

21072093

2108-
p = float(input("Enter with the price: "))
2109-
import moeda
2094+
'''p = float(input("Enter with the price: "))
2095+
from uteis import moeda
2096+
21102097
# print(moeda.metade(p))
21112098
# print(moeda.moeda(moeda.metade(p)))
21122099
print(f"The half of {moeda.moeda(p)} is {moeda.moeda(moeda.metade(p))}")
21132100
print(f"The double of {p} is {moeda.dobro(p):.2f} R$")
21142101
print(f"The increase of 10% of {p} é {moeda.aumentar(p):.2f} R$") # then the value total is")
21152102
# a = moeda.totalDim(p)
21162103
# print(f" And the value is{a}")
2117-
print(f"The decrease of 10% of {p} is {moeda.diminuir(p):.2f} R$"), # then the value total is{moeda.diminuir(p)}")
2118-
'''
2104+
print(f"The decrease of 10% of {p} is {moeda.diminuir(p):.2f} R$"), # then the value total is{moeda.diminuir(p)}")'''
21192105

21202106
# CHALLENGE 109
2107+
# Modifique as funções que form criadas no desafio 107 para que elas aceitem um parâmetro a mais,
2108+
# informando se o valor retornado por elas vai ser ou não formatado pela função moeda(), desenvolvida no desafio 108.
2109+
2110+
2111+
'''p = float(input("Enter with the price: R$"))
2112+
from uteis import moeda
2113+
2114+
2115+
# print(moeda.metade(p))
2116+
# print(moeda.moeda(moeda.metade(p)))
2117+
print(f"The half of {moeda.moeda(p)} is {moeda.metade((p, True))}")
2118+
print(f"The double of {p} is {moeda.dobro(p, True)} R$")
2119+
print(f"The increase of 10% of {p} é {moeda.aumentar(p, 10, True)}") # then the value total is
2120+
# a = moeda.totalDim(p)
2121+
# print(f" And the value is{a}")
2122+
print(f"The decrease of 10% of {p} is {moeda.diminuir(p, 13, True)} R$"), # then the value total is{moeda.diminuir(p)}")'''
2123+
2124+
# CHALLENGE 110
2125+
# Adicione o módulo moeda.py criado nos desafios anteriores, uma função chamada resumo(),
2126+
# que mostre na tela algumas informações geradas pelas funções que já temos no módulo criado até aqui
2127+
2128+
2129+
'''from uteis import moeda
2130+
2131+
2132+
p = float(input("Digite o preço: R$ "))
2133+
moeda.resumo(p)'''
2134+
2135+
2136+
# CHALLENGE 111
2137+
# Crie um pacote chamado utilidadesCeV que tenha dois módulos internos chamados moeda e dado.
2138+
# Transfira todas as funções utilizadas nos desafios 107, 108 e 109 para o primeiro pacote e mantenha tudo funcionando.
2139+
2140+
'''from uteis.utilidadesCeV import moeda
2141+
# import uteis
2142+
2143+
2144+
p = float(input("Digite o preço: R$ "))
2145+
moeda.resumo(p, 12, 19)'''
2146+
2147+
# CHALLENGE 112
2148+
2149+
# Dentro do pacote utilidadesCeV que criamos no desafio 111, temos um módulo chamado dado.
2150+
# Crie uma função chamada leiaDinheiro() que seja capaz de funcionar como a função imputa(),
2151+
# mas com uma validação de dados para aceitar apenas valores que seja monetários.
2152+
2153+
'''from uteis.utilidadesCeV import dados, moeda
2154+
21212155
2156+
p = dados.leiaDinheiro("Digite o preço: R$")
2157+
moeda.resumo(p, 13, 10)
2158+
# dados.leiaDinheiro(p)
2159+
# p = float(p)
2160+
# moeda.resumo(p)
2161+
'''

moeda.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

uteis/utilidadesCeV/__init__.py

Whitespace-only changes.

uteis/utilidadesCeV/dados/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
def leiaDinheiro(b):
2+
valido = False
3+
while not valido:
4+
entrada = str(input(b)).replace(",", ".").strip()
5+
if(entrada.isalpha() or entrada == ""):
6+
print(f"\033[0;31mERROR! \"{b}\" é preço inválido!\033[m")
7+
else:
8+
valido = True
9+
return float(entrada)
10+
11+
12+
13+
# if(b.replace(",", ".").isnumeric()):
14+
# b = float(b)
15+
# moeda.resumo(b)
16+
# else:
17+
# print(f"\033[0;31mERROR! \"{b}\" é preço inválido!\033[m")
18+
# p = input("Digite o preço: R$ ")
19+
# dados.leiaDinheiro(p)
20+
# p = float(p)
21+
# moeda.resumo(p)
22+
23+
24+
# a = float(input("Enter with a value: "))
25+
# leiaDinheiro(a)

uteis/utilidadesCeV/moeda/__init__.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
def metade(charge, formato=False):
2+
'''
3+
-> Calcula o preço de um determinado preço
4+
retornando o resultado com ou sem formatoção
5+
:param charge: O preço que se quer reajustar
6+
:param formato: Quer a saída formatada ou não?
7+
:param taxa: Qual é a porcentagem de aumento
8+
:return: O valor reajustado com ou sem formatação
9+
'''
10+
# print("="*30)
11+
# if(troco == "sim"):
12+
# print("="*30)
13+
half = charge / 2
14+
return half if formato is False else moeda(half)
15+
16+
17+
def diminuir(charge, tax, formato=False):
18+
# global totalDec
19+
# global ta
20+
decrease = charge - charge * (tax/100)
21+
# def totalDim(charge):
22+
# totalDec = charge - decrease
23+
# return totalDec, decrease
24+
# # totalDec = charge - decrease
25+
return decrease if formato is False else moeda(decrease)
26+
27+
28+
def dobro(charge, formato=False):
29+
double = charge * 2
30+
return double if (formato) is False else moeda(double)
31+
32+
33+
def aumentar(charge, tax, formato=False):
34+
# global totalInc
35+
increase = charge + charge * (tax/100)
36+
# totalInc = charge + increase
37+
return increase if formato is False else moeda(charge)
38+
39+
40+
def moeda(price=0, moeda="R$"):
41+
# if(moeda == True):
42+
# moeda = "R$"
43+
return f"{moeda}{price:.2f}".replace(".", ",")
44+
# else:
45+
# if (moeda == False):
46+
# return moeda
47+
48+
49+
def resumo(price=0, taxaA=10, taxaR=5):
50+
print("="*30)
51+
print("RESUMO DO VALOR".center(30))
52+
print("="*30)
53+
print(f"Preço analisado: \t{moeda(price)}")
54+
print(f"Dobro do analisado: {dobro(price):.2f}")
55+
print(f"Metade do analisado: {metade(price):.2f}")
56+
print(f"{taxaA}% de aumento: \t{aumentar(price, taxaA, True)}")
57+
print(f"{taxaR}% de redução: \t{diminuir(price, taxaR, True)}")
58+
print("="*30)

0 commit comments

Comments
 (0)