Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
giulianor2 authored Oct 25, 2022
1 parent fd00888 commit 7be297a
Show file tree
Hide file tree
Showing 84 changed files with 1,402 additions and 0 deletions.
14 changes: 14 additions & 0 deletions 01 - Listas/00_declarando_listas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
frutas = ["laranja", "maca", "uva"]
print(frutas)

frutas = []
print(frutas)

letras = list("python")
print(letras)

numeros = list(range(10))
print(numeros)

carro = ["Ferrari", "F8", 4200000, 2020, 2900, "São Paulo", True]
print(carro)
4 changes: 4 additions & 0 deletions 01 - Listas/01_acesso_direto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
frutas = ["maçã", "laranja", "uva", "pera"]

print(frutas[0]) # maçã
print(frutas[2]) # uva
4 changes: 4 additions & 0 deletions 01 - Listas/02_indices_negativos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
frutas = ["maçã", "laranja", "uva", "pera"]

print(frutas[-1]) # pera
print(frutas[-3]) # laranja
10 changes: 10 additions & 0 deletions 01 - Listas/03_matriz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
matriz = [
[1, "a", 2],
["b", 3, 4],
[6, 5, "c"]
]

print(matriz[0]) # [1, "a", 2]
print(matriz[0][0]) # 1
print(matriz[0][-1]) # 2
print(matriz[-1][-1]) # "c"
8 changes: 8 additions & 0 deletions 01 - Listas/04_fatiamento.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
lista = ["p", "y", "t", "h", "o", "n"]

print(lista[2:]) # ["t", "h", "o", "n"]
print(lista[:2]) # ["p", "y"]
print(lista[1:3]) # ["y", "t"]
print(lista[0:3:2]) # ["p", "t"]
print(lista[::]) # ["p", "y", "t", "h", "o", "n"]
print(lista[::-1]) # ["n", "o", "h", "t", "y", "p"]
8 changes: 8 additions & 0 deletions 01 - Listas/05_iterar_listas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
carros = ["gol", "celta", "palio"]

for carro in carros:
print(carro)


for indice, carro in enumerate(carros):
print(f"{indice}: {carro}")
9 changes: 9 additions & 0 deletions 01 - Listas/06_compreensao_de_listas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Filtrar lista
numeros = [1, 30, 21, 2, 9, 65, 34]
pares = [numero for numero in numeros if numero % 2 == 0]
print(pares)

# Modificar valores
numeros = [1, 30, 21, 2, 9, 65, 34]
quadrado = [numero**2 for numero in numeros]
print(quadrado)
7 changes: 7 additions & 0 deletions 01 - Listas/07_append.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
lista = []

lista.append(1)
lista.append("Python")
lista.append([40, 30, 20])

print(lista) # [1, "Python", [40, 30, 20]]
7 changes: 7 additions & 0 deletions 01 - Listas/08_clear.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
lista = [1, "Python", [40, 30, 20]]

print(lista) # [1, "Python", [40, 30, 20]]

lista.clear()

print(lista) # []
5 changes: 5 additions & 0 deletions 01 - Listas/09_copy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
lista = [1, "Python", [40, 30, 20]]

lista.copy()

print(lista) # [1, "Python", [40, 30, 20]]
5 changes: 5 additions & 0 deletions 01 - Listas/10_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cores = ["vermelho", "azul", "verde", "azul"]

print(cores.count("vermelho")) # 1
print(cores.count("azul")) # 2
print(cores.count("verde")) # 1
7 changes: 7 additions & 0 deletions 01 - Listas/11_extend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
linguagens = ["python", "js", "c"]

print(linguagens) # ["python", "js", "c"]

linguagens.extend(["java", "csharp"])

print(linguagens) # ["python", "js", "c", "java", "csharp"]
4 changes: 4 additions & 0 deletions 01 - Listas/12_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
linguagens = ["python", "js", "c", "java", "csharp"]

print(linguagens.index("java")) # 3
print(linguagens.index("python")) # 0
6 changes: 6 additions & 0 deletions 01 - Listas/13_pop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
linguagens = ["python", "js", "c", "java", "csharp"]

print(linguagens.pop()) # csharp
print(linguagens.pop()) # java
print(linguagens.pop()) # c
print(linguagens.pop(0)) # python
5 changes: 5 additions & 0 deletions 01 - Listas/14_remove.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
linguagens = ["python", "js", "c", "java", "csharp"]

linguagens.remove("c")

print(linguagens) # ["python", "js", "java", "csharp"]
5 changes: 5 additions & 0 deletions 01 - Listas/15_reverse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
linguagens = ["python", "js", "c", "java", "csharp"]

linguagens.reverse()

print(linguagens) # ["csharp", "java", "c", "js", "python"]
15 changes: 15 additions & 0 deletions 01 - Listas/16_sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
linguagens = ["python", "js", "c", "java", "csharp"]
linguagens.sort() # ["c", "csharp", "java", "js", "python"]
print(linguagens)

linguagens = ["python", "js", "c", "java", "csharp"]
linguagens.sort(reverse=True) # ["python", "js", "java", "csharp", "c"]
print(linguagens)

linguagens = ["python", "js", "c", "java", "csharp"]
linguagens.sort(key=lambda x: len(x)) # ["c", "js", "java", "python", "csharp"]
print(linguagens)

linguagens = ["python", "js", "c", "java", "csharp"]
linguagens.sort(key=lambda x: len(x), reverse=True) # ["python", "csharp", "java", "js", "c"]
print(linguagens)
3 changes: 3 additions & 0 deletions 01 - Listas/17_len.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
linguagens = ["python", "js", "c", "java", "csharp"]

print(len(linguagens)) # 5
4 changes: 4 additions & 0 deletions 01 - Listas/18_sorted.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
linguagens = ["python", "js", "c", "java", "csharp"]

print(sorted(linguagens, key=lambda x: len(x))) # ["c", "js", "java", "python", "csharp"]
print(sorted(linguagens, key=lambda x: len(x), reverse=True)) # ["python", "csharp", "java", "js", "c"]
30 changes: 30 additions & 0 deletions 02 - Classes e Objetos/01_desafio_bicicletaria.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Bicicleta:
def __init__(self, cor, modelo, ano, valor):
self.cor = cor
self.modelo = modelo
self.ano = ano
self.valor = valor

def buzinar(self):
print("Plim plim...")

def parar(self):
print("Parando bicicleta...")
print("Bicicleta parada!")

def correr(self):
print("Vrummmmm...")

def __str__(self):
return f"{self.__class__.__name__}: {', '.join([f'{chave}={valor}' for chave, valor in self.__dict__.items()])}"


b1 = Bicicleta("vermelha", "caloi", 2022, 600)
b1.buzinar()
b1.correr()
b1.parar()
print(b1.cor, b1.modelo, b1.ano, b1.valor)

b2 = Bicicleta("verde", "monark", 2000, 189)
print(b2)
b2.correr()
15 changes: 15 additions & 0 deletions 02 - Tuplas/00_declarando_tuplas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
frutas = (
"laranja",
"pera",
"uva",
)
print(frutas)

letras = tuple("python")
print(letras)

numeros = tuple([1, 2, 3, 4])
print(numeros)

pais = ("Brasil",)
print(pais)
4 changes: 4 additions & 0 deletions 02 - Tuplas/01_acesso_direto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
frutas = ("maçã", "laranja", "uva", "pera",)

print(frutas[0]) # maçã
print(frutas[2]) # uva
9 changes: 9 additions & 0 deletions 02 - Tuplas/03_indices_negativos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
frutas = (
"maçã",
"laranja",
"uva",
"pera",
)

print(frutas[-1]) # pera
print(frutas[-3]) # laranja
10 changes: 10 additions & 0 deletions 02 - Tuplas/04_matriz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
matriz = (
(1, "a", 2),
("b", 3, 4),
(6, 5, "c"),
)

print(matriz[0]) # (1, "a", 2)
print(matriz[0][0]) # 1
print(matriz[0][-1]) # 2
print(matriz[-1][-1]) # "c"
8 changes: 8 additions & 0 deletions 02 - Tuplas/05_fatiamento.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tupla = ("p", "y", "t", "h", "o", "n",)

print(tupla[2:]) # ("t", "h", "o", "n")
print(tupla[:2]) # ("p", "y")
print(tupla[1:3]) # ("y", "t")
print(tupla[0:3:2]) # ("p", "t")
print(tupla[::]) # ("p", "y", "t", "h", "o", "n")
print(tupla[::-1]) # ("n", "o", "h", "t", "y", "p")
12 changes: 12 additions & 0 deletions 02 - Tuplas/06_iterar_tuplas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
carros = (
"gol",
"celta",
"palio",
)

for carro in carros:
print(carro)


for indice, carro in enumerate(carros):
print(f"{indice}: {carro}")
10 changes: 10 additions & 0 deletions 02 - Tuplas/07_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cores = (
"vermelho",
"azul",
"verde",
"azul",
)

print(cores.count("vermelho")) # 1
print(cores.count("azul")) # 2
print(cores.count("verde")) # 1
4 changes: 4 additions & 0 deletions 02 - Tuplas/08_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
linguagens = ("python", "js", "c", "java", "csharp",)

print(linguagens.index("java")) # 3
print(linguagens.index("python")) # 0
9 changes: 9 additions & 0 deletions 02 - Tuplas/09_len.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
linguagens = (
"python",
"js",
"c",
"java",
"csharp",
)

print(len(linguagens)) # 5
8 changes: 8 additions & 0 deletions 03 - Conjuntos/00_declarando_conjuntos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
numeros = set([1, 2, 3, 1, 3, 4])
print(numeros) # {1, 2, 3, 4}

letras = set("abacaxi")
print(letras) # {"b", "a", "c", "x", "i"}

carros = set(("palio", "gol", "celta", "palio"))
print(carros) # {"gol", "celta", "palio"}
5 changes: 5 additions & 0 deletions 03 - Conjuntos/01_acessando_dados.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
numeros = {1, 2, 3, 2}

numeros = list(numeros)

print(numeros[0])
7 changes: 7 additions & 0 deletions 03 - Conjuntos/02_iterar_conjuntos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
carros = {"gol", "celta", "palio"}

for carro in carros:
print(carro)

for indice, carro in enumerate(carros):
print(f"{indice}: {carro}")
5 changes: 5 additions & 0 deletions 03 - Conjuntos/03_union.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
conjunto_a = {1, 2}
conjunto_b = {3, 4}

resultado = conjunto_a.union(conjunto_b)
print(resultado)
5 changes: 5 additions & 0 deletions 03 - Conjuntos/04_intersection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
conjunto_a = {1, 2, 3}
conjunto_b = {2, 3, 4}

resultado = conjunto_a.intersection(conjunto_b)
print(resultado)
8 changes: 8 additions & 0 deletions 03 - Conjuntos/05_difference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
conjunto_a = {1, 2, 3}
conjunto_b = {2, 3, 4}

resultado = conjunto_a.difference(conjunto_b)
print(resultado)

resultado = conjunto_b.difference(conjunto_a)
print(resultado)
5 changes: 5 additions & 0 deletions 03 - Conjuntos/06_symmetric_difference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
conjunto_a = {1, 2, 3}
conjunto_b = {2, 3, 4}

resultado = conjunto_a.symmetric_difference(conjunto_b)
print(resultado)
8 changes: 8 additions & 0 deletions 03 - Conjuntos/07_issubset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
conjunto_a = {1, 2, 3}
conjunto_b = {4, 1, 2, 5, 6, 3}

resultado = conjunto_a.issubset(conjunto_b) # True
print(resultado)

resultado = conjunto_b.issubset(conjunto_a) # False
print(resultado)
8 changes: 8 additions & 0 deletions 03 - Conjuntos/08_issuperset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
conjunto_a = {1, 2, 3}
conjunto_b = {4, 1, 2, 5, 6, 3}

resultado = conjunto_a.issuperset(conjunto_b) # False
print(resultado)

resultado = conjunto_b.issuperset(conjunto_a) # True
print(resultado)
9 changes: 9 additions & 0 deletions 03 - Conjuntos/09_isdisjoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
conjunto_a = {1, 2, 3, 4, 5}
conjunto_b = {6, 7, 8, 9}
conjunto_c = {1, 0}

resultado = conjunto_a.isdisjoint(conjunto_b) # True
print(resultado)

resultado = conjunto_a.isdisjoint(conjunto_c) # False
print(resultado)
10 changes: 10 additions & 0 deletions 03 - Conjuntos/10_add.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sorteio = {1, 23}

sorteio.add(25) # {1, 23, 25}
print(sorteio)

sorteio.add(42) # {1, 23, 25, 42}
print(sorteio)

sorteio.add(25) # {1, 23, 25, 42}
print(sorteio)
7 changes: 7 additions & 0 deletions 03 - Conjuntos/11_clear.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sorteio = {1, 23}

print(sorteio) # {1,23}

sorteio.clear()

print(sorteio) # {}
7 changes: 7 additions & 0 deletions 03 - Conjuntos/12_copy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sorteio = {1, 23}

print(sorteio) # {1, 23}

sorteio.copy()

print(sorteio) # {1, 23}
8 changes: 8 additions & 0 deletions 03 - Conjuntos/13_discard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
numeros = {1, 2, 3, 1, 2, 4, 5, 5, 6, 7, 8, 9, 0}

print(numeros) # {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}

numeros.discard(1)
numeros.discard(45)

print(numeros) # {2, 3, 4, 5, 6, 7, 8, 9, 0}
6 changes: 6 additions & 0 deletions 03 - Conjuntos/14_pop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
numeros = {1, 2, 3, 1, 2, 4, 5, 5, 6, 7, 8, 9, 0}

print(numeros) # {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
print(numeros.pop()) # 0
print(numeros.pop()) # 1
print(numeros) # {2, 3, 4, 5, 6, 7, 8, 9}
5 changes: 5 additions & 0 deletions 03 - Conjuntos/15_remove.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
numeros = {1, 2, 3, 1, 2, 4, 5, 5, 6, 7, 8, 9, 0}

print(numeros) # {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
print(numeros.remove(0)) # 0
print(numeros) # {1, 2, 3, 4, 5, 6, 7, 8, 9}
Loading

0 comments on commit 7be297a

Please sign in to comment.