-
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
0 parents
commit 73d831f
Showing
37 changed files
with
1,072 additions
and
0 deletions.
There are no files selected for viewing
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,3 @@ | ||
Extensões do VSCODE a serem instaladas | ||
- 1. | ||
- 2. |
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 @@ | ||
# curso-python Bóson Treinamentos |
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,64 @@ | ||
# Install with 'pip install ms_active_directory' | ||
from ms_active_directory import ADDomain | ||
|
||
|
||
domain_dns_name = 'tiozaodolinux.com' | ||
domain_servers = ['ldaps://auth.tiozaodolinux.com'] | ||
domain_user='[email protected]' | ||
domain_password='SuperSecretPassword@2025' | ||
domain_user_attrs=['cn', 'sn', 'title', 'description', 'physicalDeliveryOfficeName', 'telephoneNumber', 'givenName', 'displayName', | ||
'department', 'company', 'name', 'sAMAccountName', 'userPrincipalName', 'mail', 'loginShell', 'objectGUID', 'objectSid' ] | ||
domain_group_attrs=['cn', 'sn', 'description', 'name', 'sAMAccountName', 'member', 'objectGUID', 'objectSid'] | ||
|
||
domain = ADDomain(domain_dns_name, ldap_servers_or_uris=domain_servers) | ||
session = domain.create_session_as_user(user=domain_user, password=domain_password) | ||
|
||
# # find_functional_level returns an enum indicating the level. | ||
# # decision making based on level should be done based on the | ||
# # needs of your application | ||
# print(domain.find_functional_level()) | ||
|
||
# # might print "['EXTERNAL', 'DIGEST-MD5']" | ||
# print(domain.find_supported_sasl_mechanisms()) | ||
|
||
# # returns a python datetime object in utc time | ||
# curr_time = domain.find_current_time() | ||
|
||
# # allowed drift defaults to 5 minutes which is the kerberos standard, | ||
# # but we can use a shorter window to detect drift before it causes an | ||
# # outage. this returns a boolean | ||
# synced = domain.is_close_in_time_to_localhost(allowed_drift_seconds=60) | ||
|
||
# # returns a map that maps server hostnames -> ip addresses, where | ||
# # the hostnames are computers running dns services | ||
# dns_map = session.find_dns_servers_for_domain() | ||
# ip_addrs = dns_map.values() | ||
# hostnames = dns_map.keys() | ||
# print(f'DNS MAP = {dns_map}') | ||
# print(f'IP ADDRS = {ip_addrs}') | ||
# print(f'hostnames = {hostnames}') | ||
|
||
# Find user by name | ||
user = session.find_user_by_sam_name('tiozao', domain_user_attrs) | ||
|
||
# Find group by name | ||
group = session.find_group_by_sam_name('Turma da Monica', domain_group_attrs) | ||
|
||
# users and groups support a generic "get" for any attributes queried | ||
print() | ||
print(f''.rjust(70,'=')) | ||
print(f'USER:'.ljust(10,'.'),f'{user.distinguished_name}') | ||
print(f''.rjust(70,'=')) | ||
for attr in domain_user_attrs: | ||
if user.get(attr) != None: | ||
print(attr.ljust(30,'-'),' : ',user.get(attr)) | ||
|
||
print() | ||
print(f''.rjust(70,'=')) | ||
print(f'GROUP:'.ljust(10,'.'),f'{group.distinguished_name}') | ||
print(f''.rjust(70,'=')) | ||
|
||
for attr in domain_group_attrs: | ||
if group.get(attr) != None: | ||
print(attr.ljust(30,'-'),' : ',group.get(attr)) | ||
# print(f'{attr}:\t\t{group.get(attr)}') |
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,28 @@ | ||
import random | ||
|
||
# valor = random.randint(1,20) | ||
# print(valor) | ||
|
||
# print('Gerar cinco números aleatórios entre 1 e 50: \n') | ||
# for i in range(5): | ||
# n=random.randint(1,50) | ||
# print(f'Número gerado: {n}') | ||
|
||
# valor = random.random() # gera um aleatório entre 0 e 1 | ||
# print(f'Número gerado: {round(valor*10,2)}') # aleatório entre 1 e 10 com duas casas decimais | ||
|
||
# valor = random.uniform(1,100) | ||
# print(f'Número: {round(valor,4)}') # entre 1 e 100 com duas decimais | ||
|
||
L=[2,4,6,9,10,13,14,16,18,20,21,27,33] | ||
# n=random.choice(L) | ||
# print(f'Número escolhido: {n}') # um aleatório de uma lista | ||
|
||
# n = random.sample(L,3) # três valores da lista L | ||
# print(f'Números escolhidos: {n}') | ||
|
||
# Embaralhar | ||
print(f'Exibir a lista original: {L}') | ||
print(f'Embaralhar a lista e exibí-la:') | ||
n=random.shuffle(L) | ||
print(L) |
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,5 @@ | ||
Um arquivo é uma área em um dispositivo de armazenamento onde gravamos e lemos dados. | ||
Arquivos de texto simples (plano) são uma sequência estruturada de linhas, contendo caracteres, sem informações sobre formatação. | ||
Cada linha de um arquivo de texto é terminada com um caractere especial de fim de linha, o EOL (End Of Line) | ||
No geral, o caractere EOL é o \n. | ||
|
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,27 @@ | ||
# Manipulação de arquivos de texto | ||
|
||
# manipulador = open('arquivo.txt','r', encoding='utf-8') | ||
|
||
# print(f'Método read():\n') | ||
# print(manipulador.read()) | ||
|
||
# print(f'Método readline():\n') | ||
# print(manipulador.readline()) | ||
# print(manipulador.readline()) | ||
|
||
# print(f'Método readlines():\n') | ||
# print(manipulador.readlines()) | ||
|
||
try: | ||
manipulador = open('arquivo.txt','r', encoding='utf-8') | ||
for linha in manipulador: | ||
linha = linha.rstrip() | ||
print(linha) | ||
except IOError: | ||
print(f'Não foi possível abrir o arquivo') | ||
else: | ||
manipulador.close() | ||
|
||
|
||
|
||
|
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 @@ | ||
# Compreensões de lista | ||
# Sintaxe | ||
# expressão for item in lista | ||
|
||
# criar uma lista de quadrados de outra lista | ||
numeros = [1,4,7,9,10,12,21] | ||
|
||
# método utilizando list e map com lambda | ||
quadrados = list(map(lambda num: num**2, numeros)) | ||
print(quadrados) | ||
|
||
# método utilizando compreensão de lista | ||
quadrados = [num**2 for num in numeros] | ||
print(quadrados) | ||
|
||
# criar uma lista de números pares de 0 a 10 | ||
pares = [num for num in range(11) if num % 2 == 0] | ||
print(pares) | ||
|
||
# contar qtde de vogais numa frase | ||
frase = 'A lógica é apenas o princípio da sabedoria, e não o seu fim.' | ||
vogais = ['a','e','i','o','u','á','é','í','ó','ú'] | ||
|
||
lista_vogais = [v for v in frase if v in vogais] | ||
print(f'A frase "{frase}" possui {len(lista_vogais)} vogais') | ||
|
||
# distributiva entre valores de duas listas | ||
distributiva = [k * m for k in [2,3,5] for m in [10,20,30]] | ||
print(distributiva) |
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 @@ | ||
# Simpes, Composto, Encadeado | ||
|
||
## Calcular média | ||
|
||
n1 = n2 = 0.0 | ||
media = 0.0 | ||
|
||
n1=float(input('Digite a primeira nota: ')) | ||
n2=float(input('Digite a segunda nota: ')) | ||
# Calcular a média aritmética das notas | ||
media = (n1 + n2) / 2 | ||
|
||
if (media >= 7): | ||
print('Resultado: Aprovado') | ||
print('Parabéns!') | ||
elif (media >= 5): | ||
print('Aluno está de recuperação...') | ||
else: | ||
print('Aluno reprovado...') | ||
|
||
print('Sua média é {}'.format(media)) |
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,55 @@ | ||
# Set são conjuntos (não tem valores duplicados) | ||
|
||
planeta_anao = {'Plutão', 'Ceres', 'Eris', 'Haumea', 'Makemake'} | ||
print(planeta_anao) | ||
# print(len(planeta_anao)) | ||
|
||
# print('Ceres' in planeta_anao) | ||
# print('Lua' not in planeta_anao) | ||
|
||
for astro in planeta_anao: | ||
print(astro.upper()) | ||
|
||
astros = ['Lua', 'Venus', 'Sirius', 'Marte', 'Lua'] | ||
print(astros) | ||
astros_set = set(astros) | ||
print(astros_set) | ||
|
||
astros1 = {'Lua', 'Venus', 'Sirius', 'Marte', 'Lua', 'Io'} | ||
astros2 = {'Lua', 'Venus', 'Sirius', 'Marte', 'Lua', 'Cometa Halley'} | ||
print(astros1 != astros2) | ||
|
||
# união de conjuntos | ||
print(astros1 | astros2) | ||
print(astros1.union(astros2)) | ||
|
||
# intersecção de conjuntos | ||
print(astros1 & astros2) | ||
print(astros1.intersection(astros2)) | ||
|
||
# diferença simétrica | ||
print(astros1 ^ astros2) | ||
print(astros1.symmetric_difference(astros2)) | ||
|
||
# adicionar elementos | ||
astros1.add('Urano') | ||
astros1.add('Sol') | ||
print(astros1) | ||
|
||
# remover elementos | ||
astros1.remove('Io') | ||
print(astros1) | ||
|
||
# se não existir não dá erro na remoção | ||
astros1.discard('Plutão') | ||
print(astros1) | ||
|
||
# remoção aleatoriamente | ||
astros1.pop() | ||
print(astros1) | ||
|
||
|
||
|
||
|
||
|
||
|
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,49 @@ | ||
# Dicionários permitem armazenar dados em pares (chaves, valor) - "arrays associativos" | ||
|
||
elemento = { | ||
'z': 3, | ||
'nome': 'Lítio', | ||
'grupo': 'Metais Alcalinos', | ||
'densidade': 0.534 | ||
} | ||
|
||
print(elemento) | ||
|
||
print(f"Elemento: {elemento['nome']}") | ||
print(f"Densidade: {elemento['densidade']}") | ||
print(f'O dicionário possui {len(elemento)} elementos') | ||
|
||
# Atualizar uma entrada | ||
elemento['grupo']='Alcalinos' | ||
print(elemento) | ||
|
||
# Adicionar uma entrada | ||
elemento['periodo']=1 | ||
print(elemento) | ||
|
||
# Exclusão de entrada | ||
del elemento['periodo'] | ||
print(elemento) | ||
|
||
# # Limpar dicioinario | ||
# elemento.clear() | ||
# print(elemento) | ||
|
||
# del elemento | ||
# print(elemento) | ||
|
||
print(elemento.items()) | ||
for i in elemento.items(): | ||
print(i) | ||
|
||
print(elemento.keys()) | ||
for i in elemento.keys(): | ||
print(i) | ||
|
||
print(elemento.values()) | ||
for i in elemento.values(): | ||
print(i) | ||
|
||
# Desempacotar itens e chaves | ||
for i, j in elemento.items(): | ||
print(f'{i}: {j}') |
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,17 @@ | ||
# Escopo Global e Local | ||
|
||
var_global = 'Curso Completo de Python' | ||
|
||
def escreve_texto(): | ||
global var_global | ||
var_global = 'Bancos de Dados com SQL' | ||
var_local = "Jarbas Peixoto" | ||
print(f'Variável Global: {var_global}') | ||
print(f'Variável Local: {var_local}') | ||
|
||
print(f'Executa a função escreve_texto()') | ||
escreve_texto() | ||
|
||
print('Tentar acessar as variáveis diretamente') | ||
print(f'Variável Global: {var_global}') | ||
#print(f'Variável Local: {var_local}') |
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 @@ | ||
from math import sqrt | ||
|
||
class NumeroNegativoError(Exception): | ||
def __init__(self): | ||
pass | ||
|
||
if __name__ == '__main__': | ||
try: | ||
num = int(input("Digite um número positivo: ")) | ||
if num < 0: | ||
raise NumeroNegativoError | ||
except NumeroNegativoError: | ||
print(f'Foi fornecido um número negativo') | ||
else: | ||
print(f'A raiz quadada de {num} é {sqrt(num)}') | ||
finally: | ||
print(f'Fim do cálculo.') | ||
|
||
|
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,27 @@ | ||
# Excessão é um objeto que representa um erro ao executar o programa | ||
# Blocos try ... except | ||
|
||
def div(k, j): | ||
return round(k / j, 2) | ||
|
||
if __name__ == '__main__': | ||
while True: | ||
try: | ||
n1=int(input('Digite um número: ')) | ||
n2=int(input('Digite outro número: ')) | ||
break | ||
except ValueError: | ||
print(f"Ocorreu um erro ao ler o valor. Tente novamente.") | ||
|
||
try: | ||
r = div(n1, n2) | ||
except ZeroDivisionError: | ||
print('Não é possível dividir por zero!') | ||
except: | ||
print('Ocorreu um erro desconhecido...') | ||
else: | ||
print(f'Resultado: {r}') | ||
finally: | ||
print('\nFim do cálculo') | ||
|
||
|
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,25 @@ | ||
# lista = [2,6,9,4,0,12,3,7] | ||
# for item in lista: | ||
# print(f'O valor de item = {item}') | ||
|
||
# palavra = 'Tiozão' | ||
# for letra in palavra: | ||
# print(f'O valor da letra = {letra}') | ||
|
||
# for numero in range(1,11): | ||
# print(numero) | ||
|
||
# nome = input('Digite seu nome: ') | ||
# for x in range(10): | ||
# print(f'{x+1} {nome}') | ||
|
||
# range(valor_inicial, valor_final +1, incremento) | ||
# for x in range(21,2,-3): | ||
# print(x) | ||
|
||
# Tuplas | ||
pedras = ('Rubi', 'Esmeralda', 'Quartzo', 'Safira', 'Diamente', 'Turmalina') | ||
for pedra in pedras: | ||
if pedra == 'Quartzo': | ||
continue | ||
print(pedra) |
Oops, something went wrong.