-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78c32ee
commit 943d168
Showing
227 changed files
with
5,132 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
pacote_dowload/Modulos/.idea/inspectionProfiles/profiles_settings.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Programa principal | ||
# from uteis import fatorial, dobro - não é tão indicado para não haver conflito | ||
# from random import randint - módulo, função | ||
# tivemos vários exemplos | ||
import uteis | ||
num = int(input('Digite um valor: ')) | ||
fat = uteis.fatorial(num) | ||
print(f'O fatorial de {num} é {fat}') | ||
print(f'O dobro de {num} é {uteis.dobro(num)}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Funcionalidades eu coloco em nesse arquivo | ||
def fatorial(n): | ||
f = 1 | ||
for c in range(1, n+1): | ||
f *= c | ||
return f | ||
|
||
def dobro(n): | ||
return n * 2 | ||
|
||
|
||
def triplo(n): | ||
return n * 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"""Dicas e informações | ||
Não teve conteúdo em si""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"""ESTRUTURAS CONDICIONAIS ANINHADAS""" | ||
|
||
# ESTRUTURA CONDICIONAL COMPOSTA | ||
nome = str(input('Qual é o seu nome? ')) | ||
print(f'Tenha um bom dia, {nome}') | ||
if nome == 'Gustavo': | ||
print('Que nome bonito!') | ||
|
||
# COLOCANDO ELIF - TORNA-SE UMA ESTRUTURA CONDICIONAL ANINHADA | ||
# POSSO USAR QUANTAS VEZES EU QUISER O ELIF | ||
# UMA COISA DENTRO DA OUTRA | ||
elif nome == 'Pedro' or nome == 'Maria' or nome == 'Paulo': | ||
print('Seu nome é bem popular no Brasil.') | ||
elif nome in 'Ana, Cláudia, Jéssica, Juliana': # dentro desses exemplos | ||
print('Belo nome feminino!') | ||
|
||
# SEM O ELSE NÃO APRESENTA ESSA MENSAGEM, PORÉM, É OPCIONAL | ||
else: | ||
print('Seu nome é bem comum...') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
"""imagina que eu faço um print de 'oi' - 6 vezes, mas imagina que seriam 10000 vezes. Complicado""" | ||
|
||
# ESTRUTURA DE REPETIÇÃO - USO DO FOR IN RANGE | ||
|
||
# for c in range (1, 6): | ||
# print('Oi') | ||
# print('FIM') | ||
|
||
"""por que ele escreveu 5 vezes e não 6? - de 1 até 5, no 6 ele para, ele não considera o último | ||
de zero a 6 - aí ele considera | ||
""" | ||
# for c in range (0, 6): | ||
# print('Oi') | ||
# print('FIM') | ||
|
||
# for c in range (0, 6): | ||
# print('Oi') | ||
# print('FIM') | ||
""" eu coloquei uma tabulação a mais, olha como ele se comporta agora: Oi, FIM, Oi, FIM | ||
O COMANDO FIM ESTÁ DENTRO DO COMANDO FOR, CUIDADO COM ESSA IDENTAÇÃO | ||
""" | ||
# for c in range (0, 6): | ||
# print(c) | ||
# print('FIM') | ||
# se eu colocar o 'c' - que nem definido está, ele imprime de 0 até 5, seguido do FIM | ||
|
||
"""# preciso de uma contagem de 1 até 6""" | ||
# for c in range (1, 7): | ||
# print(c) | ||
# print('FIM') | ||
|
||
"""contagem de 6 até - ZERO, o que seria para trás, na regressiva, tem que colocar o - 1: | ||
- 1 - qual é a iteração | ||
o que é que vai acontecer no final do laço (vai tirar um de cada um dos elementos) """ | ||
# for c in range (6, 0, -1): # não apareceu o zero | ||
# print(c) | ||
# print('FIM') | ||
|
||
""" se eu colocar 0, 7, 6 - ele coloca múltiplos de 2 | ||
ele contou de zero até sete | ||
pulando de dois em dois | ||
faça vários testes """ | ||
|
||
# for c in range (0, 7, 2): # não apareceu o zero | ||
# print(c) | ||
# print('FIM') | ||
|
||
"""exemplo de contador, novamente, dessa forma, com o input" | ||
- saída: não vem o número 7 | ||
para incluir o 7 tem que ser n+1""" | ||
|
||
# n = int(input('Digite um valor: ')) | ||
# for c in range(0, n): | ||
# print(c) | ||
# print('Fim') | ||
|
||
""" eu consigo ler um valor, aqui em 'n' - do input | ||
e utilizar esse 'n' | ||
como parte de passagem para o 'for' | ||
posso usar essa mesma linha de raciocínio de várias maneiras """ | ||
# n = int(input('Digite um valor: ')) | ||
# for c in range(0, n+1): | ||
# print(c) | ||
# print('Fim') | ||
|
||
""" | ||
3 valores | ||
incío | ||
fim e | ||
passo | ||
Resposta: entendi que começa a contagem a partir do 2 vai até 9+1 e de 3 em três | ||
Saída: 2, 5, 8, Fim | ||
Exemplo 2: Início 1, Fim 100, Passo 10 | ||
Saída: 1, 11, 21, 31 ... 91, Fim | ||
""" | ||
# i = int(input('Inicio: ')) | ||
# f = int(input('Fim: ')) | ||
# p = int(input('Passo: ')) | ||
# for c in range(i, f+1, p): | ||
# print(c) | ||
# print('Fim') | ||
|
||
"""Imagina que eu tenho que pedir 10 vezes o valor ao usuário | ||
cria o laço para que seja repetido (0 ,10) | ||
define a variável de repetição - n | ||
esaída: digite um valor: 10 vezes | ||
""" | ||
# for c in range(0, 10): | ||
# n = int(input('Digite um valor:')) | ||
# print('Fim') | ||
|
||
''' | ||
eu quero ter o somatório desses números | ||
eu crio o laço | ||
defino 's' recebendo zero | ||
e faço a soma no laço | ||
*** s = s + n *** - observa que s = s fica s+= para não ficar repetindo | ||
ou como podemos uar no Python | ||
s += n | ||
''' | ||
s = 0 | ||
for c in range(0, 4): | ||
n = int(input('Digite um valor: ')) | ||
s += n | ||
print(f'O somatório de todos os valores é {s}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"""Enquanto for diferente de zero vai analisando | ||
quantos números digitados foram par ou ímpar""" | ||
n = 1 | ||
par = impar = 0 | ||
while n != 0: | ||
n = int(input('Digite um valor: ')) | ||
if n != 0: | ||
if n % 2 == 0: | ||
par += 1 | ||
else: | ||
impar += 1 | ||
print(f'Você digitou {par} números pares e {impar} números impares') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"""Flag - condição de parada""" | ||
|
||
r = 'S' | ||
while r == 'S': | ||
n = int(input('Digite um valor: ')) | ||
r = str(input('Quer continuar? [S/N] ')).upper() | ||
print('Fim') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
""" | ||
É muito importante que a variável cont seja incrementada para evitar | ||
que o loop seja infinito | ||
""" | ||
|
||
cont = 0 | ||
while cont <= 10: | ||
print(cont, '* 5 = ', (cont * 5)) | ||
cont += 1 | ||
else: | ||
print('Tabuada do 5 calculada com sucesso!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
while True: | ||
nome = input('Qual o seu nome? ') | ||
print(f'Olá, {nome}!') | ||
|
||
# print(Nunca será executado se estiver fora do laço porque não tem uma | ||
# flag ou condição de parada) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"""Usando o debug do Pycharm para verificar | ||
como ele executa linha por linha do código | ||
enquanto a condição de X < 5 == True""" | ||
|
||
x = 0 | ||
while x < 5: | ||
print(x) | ||
x += 1 | ||
print('Acabou') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
x = 0 | ||
while x < 10: | ||
if x == 3: | ||
x = x + 1 | ||
break | ||
print(x) | ||
x = x + 1 | ||
print('Acabou') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"""Laço dentro de um laço""" | ||
|
||
x = 0 # coluna | ||
while x < 10: | ||
y = 0 | ||
|
||
while y < 5: | ||
print(f'{x}, {y}') | ||
y += 1 | ||
x += 1 | ||
|
||
print('Acabou') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""Calculadora básica""" | ||
|
||
while True: | ||
print() | ||
num1 = input('Digite um número: ') | ||
num2 = input('Digite outro número: ') | ||
operador = input('Digite um operador: ') | ||
sair = input('Deseja sair? [s]im ou [n]]ão ') | ||
|
||
if sair == 's': | ||
break | ||
|
||
if not num1.isnumeric() or not num2.isnumeric(): | ||
print('Você precisa digitar um número válido.') | ||
continue | ||
|
||
num1 = int(num1) | ||
num2 = int(num2) | ||
|
||
if operador == '+': | ||
print(num1 + num2) | ||
elif operador == '-': | ||
print(num1 - num2) | ||
elif operador == '/': | ||
print(num1 / num2) | ||
elif operador == '*': | ||
print(num1 * num2) | ||
else: | ||
print('Operador inválido') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
contador = 1 | ||
acumulador = 1 | ||
|
||
while contador <= 10: | ||
print(contador, acumulador) | ||
acumulador = acumulador + contador | ||
contador += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
lanche = ('hamburguer', 'pizza', 'suco', 'pudim', 'batata frita') | ||
|
||
# pessoa = 'Gustavo', 39, 'M', 99.88 # pode ter dados de tipos diferentes | ||
# del(pessoa) # apaga da memória, por isso gera erro na hora de mandar o print posteriormente | ||
# NameError: name 'pessoa' is not defined | ||
# del(pessoa[1]) | ||
# TypeError: 'tuple' object doesn't support item deletion | ||
# print(pessoa) | ||
|
||
# a = 2, 5, 4 | ||
# b = 5, 8, 1, 2 | ||
# c = b + a # fica com todos os elementos das tuplas, respeitando a ordem do b primeiro e depois o a | ||
# print(len(c)) # aparece a quantidade de elementos do 'c' | ||
# print(c.count(5)) # aparece o resultado de quantas vezes aquele elemento aparece na tupla 'c' | ||
# print(c) | ||
# print(c.index(2)) # como tem duas ocorrências, ele pega somente a primeira | ||
|
||
# tuplas são imutáveis, exceto para DELETAR A TUPLA INTEIRA, NÃO DÁ PARA DELETAR ITENS! | ||
# lanche[1] = 'refrigerante' | ||
# TypeError: 'tuple' object does not support item assignment | ||
|
||
# print(lanche[-2:]) | ||
# se eu quiser fazer diferente usando cada uma das comidas: | ||
|
||
# # esse print eu uso minha variável composta | ||
for comida in lanche: | ||
print(f'Eu vou comer {comida}...') | ||
print('Comi pra caramba!') | ||
|
||
# se eu quiser usar o LEN e usar o range: | ||
# for cont in range(0, len(lanche)): | ||
# print(f'Eu vou comer {lanche[cont]}... na posição {cont}') | ||
# print('Comi pra caramba!') | ||
|
||
# eu posso ter o mesmo resultado usando ENUMERATE | ||
# a variável pos é criada e recebe os valores apresentados pelo enumerate | ||
# for pos, comida in enumerate(lanche): | ||
# print(f'Eu vou comer {comida}... na posição {pos}') | ||
# print('Comi pra caramba!') | ||
|
||
# uma outra forma é usando o SORTED = COLOCAR EM ORDEM ALFABÉTICA, NUMÉRICA, EM 'ORDEM' | ||
# observa que no print é possível verificar que o sorted coloca em colchetes, ele teve que fazer lista | ||
# sorted não altera a tupla, só coloca em ordem | ||
# print(sorted(lanche)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
lanche = 'hamburguer', 'suco', 'pizza', 'pudim' | ||
print(lanche) | ||
# print(lanche[-3:]) | ||
# # não posso atribuir valores a tuplas - tuplas são imutáveis | ||
# TypeError: 'tuple' object does not support item assignment | ||
# lanche[1] = 'refrigerante' | ||
# print(lanche[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
""" | ||
VARIÁVEIS COMPOSTAS - LISTAS | ||
""" | ||
num = [2, 5, 9, 1] | ||
num[2] = 3 # alterar o valor | ||
# num[4] = 7 # erro no modo de inserção | ||
num.append(7) # inclui no último elemento | ||
num.sort(reverse=True) # ordem reversa | ||
# num.insert(2, 0) # na posição 2, inserir o valor zero | ||
num.insert(2, 2) | ||
# num.remove(2) # ele remove o primeiro elemento encontrado com o valor a ser eliminado | ||
"""ficando, portanto, a lista 7, 5, 3, 2, 1 | ||
esse segundo dois ele não tira!""" | ||
if 4 in num: | ||
num.remove(4) | ||
else: | ||
print('Eu não achei o número 4') | ||
# num.pop() # elimina o último elemento | ||
# num.pop(2) # ele elimina o segundo elemento | ||
print(num) | ||
print(f'Essa lista tem {len(num)} elementos') # para verificcar quantos elementos tem |
Oops, something went wrong.