├── ReadME.md ├── images ├── botao_apoia_se.png └── capa.png ├── level-a ├── 01 │ └── quiz.py ├── 02 │ └── guess_number.py ├── 03 │ └── rock_paper_scissors.py ├── 04 │ └── countdown.py ├── 05 │ └── password_generator.py ├── 06 │ ├── termoo.py │ └── words.json ├── 07 │ ├── __pycache__ │ │ └── functions.cpython-38.pyc │ ├── functions.py │ └── main_functions_date.py ├── 08 │ └── detect_palindromes.py └── ReadMe.md ├── level-b ├── 10 │ ├── mapreduce.py │ └── reduce_examples.py ├── 11 │ └── nba_scores.py ├── 12 │ ├── __pycache__ │ │ └── convert_currency.cpython-38.pyc │ ├── convert_currency.py │ └── main.py ├── 13 │ ├── __pycache__ │ │ └── web_scraping.cpython-38.pyc │ ├── main.py │ └── web_scraping.py ├── 14 │ ├── Logic_Gate.py │ ├── __pycache__ │ │ └── Logic_Gate.cpython-38.pyc │ ├── diagram.plantuml │ ├── logics_gates_diagram.png │ └── main.py ├── 09 │ ├── aquarium.json │ ├── aquarium_manager.py │ └── aquarium_manager_2.py └── ReadMe.md └── level-c ├── 16 ├── esquematizacao_fac.plantuml ├── esquematizacao_prob.plantuml └── factory_method.py ├── 17 ├── abstract_factory.py ├── esquematizacao_prob.plantuml └── esquematizacao_sol.plantuml ├── 18 ├── entrada_usuario.json ├── modulo.py ├── saida_req_instagram.json └── saida_req_linkedin.json ├── 19 ├── __pycache__ │ └── database.cpython-38.pyc ├── client.py ├── client_without_singleton.py └── database.py └── 20 ├── __pycache__ ├── adapter.cpython-311.pyc ├── client_code.cpython-311.pyc ├── data.cpython-311.pyc ├── data_2.cpython-311.pyc └── data_dict.cpython-311.pyc ├── adapter.py ├── client_code.py ├── data_dict.py ├── data_list.py ├── esquematizacao_prob.plantuml └── main.py /ReadME.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Projetos em Python para Iniciantes 4 | 5 |

Projetos em Python para Iniciantes

6 |

7 | 8 | ## 🎯 Aprenda Python praticando com exemplos e projetos 9 | 10 | Abaixo você encontrará conteúdos para te guiar e ajudar a aprender Python, praticando por meio da construção de mini-projetos e exemplos práticos. 11 | 12 | Segue nas redes sociais para acompanhar mais conteúdo:
13 | [](https://github.com/iuryrosal) 14 | [](https://www.linkedin.com/in/iuryrosal/) 15 | [](https://www.youtube.com/channel/UC0bUO0t7Hv7vTBCxUecj_aw) 16 |
17 | 18 | ## ⚠️ Aviso importante 19 | 20 | > Antes de tudo você pode me ajudar, deu bastante trabalho fazer esse repositório e organizar para fazer seu estudo ou trabalho melhor, portanto você pode me ajudar das seguinte maneiras 21 | - Me seguindo nas redes sociais 22 | - Compartilhar o conteúdo para ajudar no alcance 23 | - Seja apoiador via Apoia-se (e tendo benefícios em troca): 24 | [](https://apoia.se/iuryrosaltech) 25 | 26 | 27 | ## 🥰 Apoiadores 28 | Sem eles nada disso seria possível: 29 | 30 | |Messias Tayllan|Aluísio Alves|Pedro Henrique|Vinicius Melo 31 | |----|---------|-------|-------------| 32 | |Tomás Coelho|Helena Oliveira|Michel Vasconcelos|José Vanderley 33 | |Victor Henrique|Andrea Sampaio|Lucilaneo Santos|Laura Santiago| 34 | 35 | Quer me apoiar nesse trabalho de produzir materiais e conteúdos, em português, para a comunidade brasileira de software e dados? Se torne apoiador via a campanha do apoia-se, com o valor simbolico mensal, além de me estimular na criação de conteúdo, irá me auxiliar nas despesas do projeto voluntário. 36 | 37 | [](https://apoia.se/iuryrosaltech) 38 | 39 | 40 | 41 | ## 📛 Direitos autorais 42 | 43 | > Alguns projetos desse repositório foram construídos e inspirados de fontes estrangeiras. Em cada vídeo do canal, na descrição, as fontes sempre são expostas. Mas, de modo geral, reúno todas elas aqui, em respeito ao ótimo trabalho dos seus criadores. 44 | - [Tech with Tim](https://www.youtube.com/c/TechWithTim) - Canal do Youtube de Tecnologia. 45 | - [Resolução de Problemas com Algoritmos e Estruturas de Dados usando Python](https://panda.ime.usp.br/pythonds/static/pythonds_pt/index.html) - Site atrelado a instituição IME-USP 46 | 47 | ## 💡 Nossa proposta 48 | 49 | > A proposta deste repositório é promover a aplicação de conhecimentos teóricos com projetos práticos, sendo um estímulo para fixar esses conhecimentos e ver seu uso em projetos reais. Além disso, com a realização dos projetos, o profissional já poderá ter um portfólio inicial, auxiliando na captação de oportunidades. Todos os conteúdos são originalmente em Português, pois o foco é agregar na comunidade brasileira e afins (que falam o mesmo idioma). 50 | ## 👑 Lançando a oportunidade 51 | 52 | > Não foque apenas em consumir os vídeos em que construo os projetos. No começo do vídeo, eu explico o escopo do que será construído. Busque construir (na sua mente ou em um papel), um esboço do desenho da solução, pode até ser em pseudocódigo. Ao longo do vídeo, você pode me seguir e ir construindo juntamente com o vídeo. Uma alternativa é, após ou antes de assistir o vídeo, construir sua própria solução, aplicando melhorias em relação ao que apresentei no vídeo. Não deixe de compartilhar sua construção e ideias (se for possível me marcar nas redes ou linkar com o canal, seria muito legal para eu visualizar e auxiliar na divulgação do trampo!) 53 | 54 | ## 🎈 Guia de Índice 55 | Os projetos/videos estão categorizados em leves. 56 | > 😄 Level A: Projetos que envolvem os primeiros passos no mundo da programação e para quem está aprendendo a linguagem Python. 57 | # 58 | > 😏 Level B: Projetos desse nível já envolvem conhecimentos um pouco mais intermediários para quem está começando. Normalmente trabalhamos com alguns paradigmas de programação, como Programação Orientada a Objetos, paralelismo e concorrência. 59 | 60 | # 61 | > 🤩 Level C: Projetos mais avançados para quem está começando. Nesses projetos lidaremos com conceitos como estruturas de dados, técnicas de construção de algoritmos, Design Patterns, métodos numéricos e aplicações dos conhecimentos de Python combinando com conhecimentos de outras áreas. 62 | 63 | ## 📚 ÍNDICE 64 | [😄 Level-A](#-level-a)
65 | [😏 Level-B](#-level-b)
66 | [🤩 Level-C](#-level-c)
67 | 68 | 69 | ## 😄 Level-A 70 | | ID | Projeto | Vídeo | Repositório | 71 | |----|---------|-------|-------------| 72 | | 01 | Quiz |[][video_01]|[][repo_01]| 73 | | 02 | Jogo de Adivinhação Numérica|[][video_02]|[][repo_02]| 74 | | 03 | Pedra, Papel e Tesoura|[][video_03]|[][repo_03]| 75 | | 04 | Temporizador|[][video_04]|[][repo_04]| 76 | | 05 | Gerador de Senha|[][video_05]|[][repo_05]| 77 | | 06 | Jogo da Adivinhação das Datas|[][video_06]|[][repo_06]| 78 | | 07 | Validando datas com funções|[][video_07]|[][repo_07]| 79 | | 08 | Detectando palindromos com recursividade|[][video_08]|[][repo_08]| 80 | 81 | ## 😏 Level-B 82 | | ID | Projeto | Vídeo | Repositório | 83 | |----|---------|-------|-------------| 84 | | 09 | Filtrando e Mapeando Animais de um Aquário |[][video_09]|[][repo_09]| 85 | | 10 | Map e Reduce em Aquário|[][video_10]|[][repo_10]| 86 | | 11 | Coletando e Exibindo Dados do NBA com API|[][video_11]|[][repo_11]| 87 | | 12 | Conversor de Moedas Orientado a Objetos|[][video_12]|[][repo_12]| 88 | | 13 | Conversor de Moedas Orientado a Objetos|[][video_13]|[][repo_13]| 89 | | 14 | Portas Lógicas e Herança |[][video_14]|[][repo_14]| 90 | | 15 | - |[][video_15]|[][repo_15]| 91 | 92 | ## 🤩 Level-C 93 | | ID | Projeto | Vídeo | Repositório | 94 | |----|---------|-------|-------------| 95 | | 16 | Padrões de Projeto: Factory Method |[][video_16]|[][repo_16]| 96 | | 17 | Padrões de Projeto: Abstract Factory |[][video_17]|[][repo_17]| 97 | | 18 | Padrões de Projeto: Builder |[][video_18]|[][repo_18]| 98 | 99 | [video_01]:https://www.youtube.com/watch?v=MRYlWPrsMYk&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 100 | [video_02]:https://www.youtube.com/watch?v=x0_mWMQLz3E&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 101 | [video_03]:https://www.youtube.com/watch?v=kO_lUkeQm4c&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 102 | [video_04]:https://www.youtube.com/watch?v=yfAixrxCVfo&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 103 | [video_05]:https://www.youtube.com/watch?v=aAImiFpG_hA&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 104 | [video_06]:https://www.youtube.com/watch?v=ridIE7ZS5KI&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 105 | [video_07]:https://www.youtube.com/watch?v=m8xBpg0knCM&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 106 | [video_08]:https://www.youtube.com/watch?v=66ugH75ao7c&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 107 | [video_09]:https://www.youtube.com/watch?v=0PvfcHCtqXw&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 108 | [video_10]:https://www.youtube.com/watch?v=yZ2ATIGXSIQ&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 109 | [video_11]:https://www.youtube.com/watch?v=ghOaY1sd9aY&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 110 | [video_12]:https://www.youtube.com/watch?v=9BwJKlLu9Ug&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 111 | [video_13]:https://www.youtube.com/watch?v=YEvoDf2azq0&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 112 | [video_14]:https://www.youtube.com/watch?v=_iCCE_VuO4g&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 113 | 114 | [video_16]:https://youtu.be/CTagrzz-GXs 115 | [video_17]:https://youtu.be/8VhaRVsUmTU 116 | [video_18]:https://youtu.be/TLppLr2R1mI 117 | 118 | [repo_01]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/01 119 | [repo_02]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/02 120 | [repo_03]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/03 121 | [repo_04]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/04 122 | [repo_05]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/05 123 | [repo_06]:https://github.com/iuryrosal/projetos-python/tree/main/level-a/06 124 | [repo_07]:https://github.com/iuryrosal/projetos-python/tree/main/level-a/07 125 | [repo_08]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/08 126 | [repo_09]:https://github.com/iuryrosal/projetos-python/tree/main/level-b/09 127 | [repo_10]:https://github.com/iuryrosal/projetos-python/tree/main/level-b/10 128 | [repo_11]:https://github.com/iuryrosal/projetos-python/blob/main/level-b/11 129 | [repo_12]:https://github.com/iuryrosal/projetos-python/blob/main/level-b/12 130 | [repo_13]:https://github.com/iuryrosal/projetos-python/blob/main/level-b/13 131 | [repo_14]:https://github.com/iuryrosal/projetos-python/blob/main/level-b/14 132 | 133 | [repo_16]:https://github.com/iuryrosal/projetos-python/tree/main/level-c/16 134 | [repo_17]:https://github.com/iuryrosal/projetos-python/tree/main/level-c/17 135 | [repo_18]:https://github.com/iuryrosal/projetos-python/tree/main/level-c/18 -------------------------------------------------------------------------------- /images/botao_apoia_se.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iuryrosal/projetos-python/45f9cf64bc7459bf1f28d36fd7556965e0633d09/images/botao_apoia_se.png -------------------------------------------------------------------------------- /images/capa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iuryrosal/projetos-python/45f9cf64bc7459bf1f28d36fd7556965e0633d09/images/capa.png -------------------------------------------------------------------------------- /level-a/01/quiz.py: -------------------------------------------------------------------------------- 1 | print("Seja muito bem vindo ao quiz do Iury!") 2 | answer_user = input("Quer começar? (S/N) ") 3 | 4 | if answer_user != "S": 5 | quit() 6 | 7 | score = 0 8 | 9 | print("Começando...") 10 | print("Quem desenvolveu o jogo Grand Theft Auto (GTA)? \n (A) Rockstar Games \n (B) Ubisoft \n (C) Activision \n (D) EA \n") 11 | answer_1 = input("Resposta: ") 12 | 13 | if answer_1 == "A": 14 | print("Correto!") 15 | score = score + 1 16 | else: 17 | print("Incorreto!") 18 | 19 | print("Qual o nome do protagonista do jogo GTA San Andreas?\n (A) Carlos John \n (B) Carl Jonhson \n (C) Carl Jaqueline \n (D) Carlos Jonhson \n") 20 | answer_2 = input("Resposta: ") 21 | 22 | if answer_2 == "B": 23 | print("Correto!") 24 | score = score + 1 25 | else: 26 | print("Incorreto!") 27 | 28 | print(f"Quiz acabou... Pontuação: {score}/2") -------------------------------------------------------------------------------- /level-a/02/guess_number.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | print("Seja muito bem vindo ao Guess Number do Iury!") 4 | choice_number = input("Digite o número teto do desafio: ") 5 | 6 | if choice_number.isdigit(): 7 | choice_number = int(choice_number) 8 | else: 9 | print("Erro: valor informado não é numérico. Favor execute novamente e informe um número!") 10 | quit() 11 | 12 | random_number = random.randint(0, choice_number) 13 | 14 | n_choices = 0 15 | 16 | while True: 17 | answer_user = input("Advinhe o número: ") 18 | 19 | if answer_user.isdigit(): 20 | answer_user = int(answer_user) 21 | else: 22 | print("Erro: valor informado não é numérico. Favor informe um número!") 23 | continue 24 | 25 | n_choices = n_choices + 1 26 | if answer_user == random_number: 27 | print("Acertou!") 28 | break 29 | elif answer_user > random_number: 30 | print("Chutou alto, o número randomico é menor que isso..") 31 | else: 32 | print("Chutou baixo, o número randomico é maior que isso..") 33 | 34 | print("N° de tentativas: " + str(n_choices)) -------------------------------------------------------------------------------- /level-a/03/rock_paper_scissors.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | user_points = 0 4 | computer_points = 0 5 | 6 | 7 | options = ["r", "t", "p"] 8 | 9 | 10 | while True: 11 | user_choice = input("Escolha R(Pedra)/T(Tesoura)/P(Papel) ou Q para sair.").lower() 12 | 13 | if user_choice == 'q': 14 | break 15 | 16 | if user_choice not in options: 17 | continue 18 | 19 | computer_choice = random.randint(0, 2) 20 | # 0 : R, 1 : T, 2 : P 21 | computer_option = options[computer_choice] 22 | 23 | print("O computador escolheu " + computer_option) 24 | 25 | if user_choice == computer_option: 26 | print("Empate!") 27 | 28 | elif user_choice == "r" and computer_option == "t": 29 | print("Você ganhou!") 30 | user_points = user_points + 1 31 | 32 | elif user_choice == "p" and computer_option == "r": 33 | print("Você ganhou!") 34 | user_points = user_points + 1 35 | 36 | elif user_choice == "t" and computer_option == "p": 37 | print("Você ganhou!") 38 | user_points = user_points + 1 39 | 40 | else: 41 | print("Você perdeu!") 42 | computer_points = computer_points + 1 43 | 44 | print("Sua pontuação: " + str(user_points)) 45 | print("Pontuação do Computador: " + str(computer_points)) 46 | 47 | if computer_points > user_points: 48 | print("Derrota!!!!") 49 | elif computer_points == user_points: 50 | print("Empate") 51 | else: 52 | print("Vitória!!") -------------------------------------------------------------------------------- /level-a/04/countdown.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | t = input("Digite o tempo (em segundos): ") 4 | 5 | if t.isdigit(): 6 | t = int(t) 7 | else: 8 | print("Entrada inválida!") 9 | quit() 10 | 11 | # 120 / 60 = 2 12 | # 150 / 60 = 2 | 30 13 | 14 | while t: 15 | minutes, seconds = divmod(t, 60) 16 | timer = "{:02d}:{:02d}".format(minutes, seconds) 17 | print(timer, end="\r") 18 | time.sleep(1) 19 | t = t - 1 20 | 21 | print("TEMPO ACABOU!!!!") 22 | 23 | -------------------------------------------------------------------------------- /level-a/05/password_generator.py: -------------------------------------------------------------------------------- 1 | import random 2 | import string 3 | 4 | def password_generator(len_pass = 8): 5 | ascii_options = string.ascii_letters 6 | number_options = string.digits 7 | punt_options = string.punctuation 8 | options = ascii_options + number_options + punt_options 9 | 10 | password_user = "" 11 | 12 | for i in range(0, len_pass): 13 | digit = random.choice(options) 14 | password_user = password_user + digit 15 | 16 | return password_user 17 | 18 | choice_user = input("Quantos digitos na senha?") 19 | 20 | if choice_user.isdigit(): 21 | choice_user = int(choice_user) 22 | else: 23 | print("Entrada inválida!") 24 | quit() 25 | 26 | response = password_generator(len_pass = choice_user) 27 | print(f"Senha gerada:\n{response}") 28 | 29 | 30 | -------------------------------------------------------------------------------- /level-a/06/termoo.py: -------------------------------------------------------------------------------- 1 | import json 2 | import random 3 | 4 | f = open("words.json", encoding="utf8") 5 | 6 | words = json.load(f) 7 | choice_c = random.choice(list(words.keys())) 8 | 9 | print("Ola, seja bem vindo!") 10 | print("#################################") 11 | 12 | n_choices = 5 13 | win = False 14 | 15 | while n_choices > 0 and win is not True: 16 | print("Dica: " + words[choice_c]) 17 | answer_user = input("Data: DDMMAAAA\n") 18 | print("################## \n") 19 | 20 | if len(answer_user) != 8: 21 | print("Erro na entrada. A resposta deve conter 8 digitos.") 22 | continue 23 | 24 | if answer_user.isdigit(): 25 | check = [] 26 | pontuation = 0 27 | for i in range(8): 28 | if answer_user[i] == choice_c[i]: 29 | check.append("✅") 30 | pontuation = pontuation + 1 31 | else: 32 | check.append("💢") 33 | 34 | print("Resposta: \n") 35 | print("|".join(check)) 36 | print(" |".join(answer_user)) 37 | print("#######################\n") 38 | 39 | if pontuation == 8: 40 | win = True 41 | else: 42 | print("Erro na entrada. A resposta deve ser uma data!") 43 | continue 44 | n_choices = n_choices - 1 45 | 46 | if win == True: 47 | print("VITÓRIA!!!") 48 | else: 49 | print("DERROTA!") 50 | print("A resposta era: " + choice_c) -------------------------------------------------------------------------------- /level-a/06/words.json: -------------------------------------------------------------------------------- 1 | { 2 | "25011654": "Fim do domínio holandês no Nordeste brasileiro", 3 | "31031964": "Golpe Militar e início da Ditadura no Brasil", 4 | "21041960": "Inauguração de Brasília (nova capital do Brasil)", 5 | "13051888": "Abolição da Escravatura (Lei Áurea)", 6 | "22081942": "Entrada do Brasil na Segunda Guerra Mundial" 7 | } -------------------------------------------------------------------------------- /level-a/07/__pycache__/functions.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iuryrosal/projetos-python/45f9cf64bc7459bf1f28d36fd7556965e0633d09/level-a/07/__pycache__/functions.cpython-38.pyc -------------------------------------------------------------------------------- /level-a/07/functions.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | 3 | def today(): 4 | today = datetime.now() 5 | return today 6 | 7 | def verify_date(date): 8 | try: 9 | date_format = datetime.strptime(date, "%d-%m-%Y") 10 | return date_format 11 | except: 12 | raise Exception("Entrada inválida! Formato sugerido: D-M-Y. Exemplo: 01-09-2000") 13 | 14 | def verify_due(date_ref): 15 | due_date = verify_date(date=date_ref) 16 | if today() > due_date: 17 | return "Data expirou..." 18 | else: 19 | return "Data não expirou..." 20 | -------------------------------------------------------------------------------- /level-a/07/main_functions_date.py: -------------------------------------------------------------------------------- 1 | from functions import * 2 | 3 | print("##########################\n") 4 | print("Qual a data de vencimento?") 5 | print("Formato: DIA-MES-ANO. Exemplo: 01-01-2000\n") 6 | print("##########################\n") 7 | 8 | due_date = input("") 9 | 10 | if len(due_date) == 10: 11 | print(verify_due(due_date)) 12 | else: 13 | print("Entrada inválida!") -------------------------------------------------------------------------------- /level-a/08/detect_palindromes.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def is_palindrome(word): 4 | j = len(word)-1 5 | result = 0 6 | for i in range(len(word)): 7 | if word[i] == word[j]: 8 | result = result + 1 9 | if i >= j: 10 | break 11 | j = j - 1 12 | 13 | if result == math.ceil(len(word)/2): 14 | return True 15 | else: 16 | return False 17 | 18 | def is_palindrome_recursive(word): 19 | if len(word) <= 1: 20 | return True 21 | else: 22 | return word[0] == word[-1] and is_palindrome_recursive(word[1:-1]) 23 | 24 | 25 | words = ["arara", "racecar", "carro", "cama", "level"] 26 | 27 | for word in words: 28 | print(word) 29 | print(is_palindrome_recursive(word)) 30 | print("\n") -------------------------------------------------------------------------------- /level-a/ReadMe.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Projetos em Python para Iniciantes 4 | 5 |

Projetos em Python para Iniciantes - Level A

6 |

7 | 8 | ## 🎯 Aprenda Python praticando com exemplos e projetos 9 | 10 | Abaixo você encontrará conteúdos para te guiar e ajudar a aprender Python, praticando por meio da construção de mini-projetos e exemplos práticos. 11 | 12 | Segue nas redes sociais para acompanhar mais conteúdo:
13 | [](https://github.com/iuryrosal) 14 | [](https://www.linkedin.com/in/iuryrosal/) 15 | [](https://www.youtube.com/channel/UC0bUO0t7Hv7vTBCxUecj_aw) 16 |
17 | 18 | ## 😄 Level-A 19 | 20 | > 😄 Level A: Projetos que envolvem os primeiros passos no mundo da programação e para quem está aprendendo a linguagem Python. 21 | 22 | | ID | Projeto | Vídeo | Repositório | 23 | |----|---------|-------|-------------| 24 | | 01 | Quiz |[][video_01]|[][repo_01]| 25 | | 02 | Jogo de Adivinhação Numérica|[][video_02]|[][repo_02]| 26 | | 03 | Pedra, Papel e Tesoura|[][video_03]|[][repo_03]| 27 | | 04 | Temporizador|[][video_04]|[][repo_04]| 28 | | 05 | Gerador de Senha|[][video_05]|[][repo_05]| 29 | | 06 | Jogo da Adivinhação das Datas|[][video_06]|[][repo_06]| 30 | | 07 | Validando datas com funções|[][video_07]|[][repo_07]| 31 | | 08 | Detectando palindromos com recursividade|[][video_08]|[][repo_08]| 32 | 33 | [video_01]:https://www.youtube.com/watch?v=MRYlWPrsMYk&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 34 | [video_02]:https://www.youtube.com/watch?v=x0_mWMQLz3E&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 35 | [video_03]:https://www.youtube.com/watch?v=kO_lUkeQm4c&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 36 | [video_04]:https://www.youtube.com/watch?v=yfAixrxCVfo&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 37 | [video_05]:https://www.youtube.com/watch?v=aAImiFpG_hA&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 38 | [video_06]:https://www.youtube.com/watch?v=ridIE7ZS5KI&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 39 | [video_07]:https://www.youtube.com/watch?v=m8xBpg0knCM&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 40 | [video_08]:https://www.youtube.com/watch?v=66ugH75ao7c&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 41 | 42 | [repo_01]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/01 43 | [repo_02]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/02 44 | [repo_03]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/03 45 | [repo_04]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/04 46 | [repo_05]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/05 47 | [repo_06]:https://github.com/iuryrosal/projetos-python/tree/main/level-a/06 48 | [repo_07]:https://github.com/iuryrosal/projetos-python/tree/main/level-a/07 49 | [repo_08]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/08 50 | [repo_09]:https://github.com/iuryrosal/projetos-python/tree/main/level-b/09 51 | [repo_10]:https://github.com/iuryrosal/projetos-python/tree/main/level-b/10 52 | [repo_11]:https://github.com/iuryrosal/projetos-python/blob/main/level-b/11 -------------------------------------------------------------------------------- /level-b/09/aquarium.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [{"name": "sammy", "species": "shark", "tank number": 11, "type": "fish"}, 3 | {"name": "ashley", "species": "crab", "tank number": 25, "type": "shellfish"}, 4 | {"name": "jo", "species": "guppy", "tank number": 18, "type": "fish"}, 5 | {"name": "jackie", "species": "lobster", "tank number": 21, "type": "shellfish"}, 6 | {"name": "charlie", "species": "clownfish", "tank number": 12, "type": "fish"}, 7 | {"name": "olly", "species": "green turtle", "tank number": 34, "type": "turtle"} 8 | ] 9 | } -------------------------------------------------------------------------------- /level-b/09/aquarium_manager.py: -------------------------------------------------------------------------------- 1 | # DESEJO COLOCAR TODOS OS ANIMAIS DO TIPO FISH NO TANQUE DE NÚMERO 42 2 | 3 | import json 4 | 5 | f = open("aquarium.json", encoding="utf8") 6 | data_aquarium = json.load(f) 7 | animals = data_aquarium["data"] 8 | 9 | def verify_fish(animal): 10 | if animal["type"] == "fish": 11 | return True 12 | return False 13 | 14 | animals_fish = list(filter(verify_fish, animals)) 15 | 16 | def animal_name(animal): 17 | return animal["name"] 18 | 19 | animals_fish_name = list(map(animal_name, animals_fish)) 20 | print(animals_fish_name) 21 | 22 | def assign_to_tank(animals, names_selected, new_tank_number): 23 | def change_tank_number(animal): 24 | if animal["name"] in names_selected: 25 | animal["tank number"] = new_tank_number 26 | return animal 27 | return list(map(change_tank_number, animals)) 28 | 29 | new_aquarium = assign_to_tank(animals, animals_fish_name, 42) 30 | print(new_aquarium) -------------------------------------------------------------------------------- /level-b/09/aquarium_manager_2.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | f = open("aquarium.json", encoding="utf8") 4 | data_aquarium = json.load(f) 5 | animals = data_aquarium["data"] 6 | 7 | def move_fishes_to_aquarium_42(animal): 8 | if animal["type"] == "fish": 9 | animal["tank number"] = 42 10 | return animal 11 | 12 | print(list(map(move_fishes_to_aquarium_42, animals))) -------------------------------------------------------------------------------- /level-b/10/mapreduce.py: -------------------------------------------------------------------------------- 1 | import json 2 | from functools import reduce 3 | 4 | f = open("../aquarium_manager/aquarium.json", encoding="utf8") 5 | data_aquarium = json.load(f) 6 | animals = data_aquarium["data"] 7 | 8 | def pick_animal_type(animal): 9 | return animal["type"], 1 10 | 11 | def reducer(acc, val): 12 | if val[0] not in acc.keys(): 13 | acc[val[0]] = 0 + val[1] 14 | else: 15 | acc[val[0]] = acc[val[0]] + val[1] 16 | return acc 17 | 18 | 19 | type_animals = list(map(pick_animal_type, animals)) 20 | print(type_animals) 21 | animals_type_count = reduce(reducer, type_animals, {}) 22 | print(animals_type_count) -------------------------------------------------------------------------------- /level-b/10/reduce_examples.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | 3 | numbers = [1, 2, 3, 4, 5] 4 | 5 | def reducer(acc, val): 6 | return acc+val 7 | 8 | print(reduce(sum, numbers, 10)) -------------------------------------------------------------------------------- /level-b/11/nba_scores.py: -------------------------------------------------------------------------------- 1 | from requests import get 2 | 3 | BASE_URL = "http://data.nba.net" 4 | ALL_JSON = "/prod/v1/today.json" 5 | 6 | def get_links(): 7 | response = get(BASE_URL+ALL_JSON).json() 8 | return response["links"] 9 | 10 | def get_currentScoreboard(): 11 | response = get(BASE_URL+get_links()["currentScoreboard"]).json() 12 | games = response["games"] 13 | 14 | for game in games: 15 | home_team = game["hTeam"] 16 | away_team = game["vTeam"] 17 | clock = game["clock"] 18 | period = game["period"] 19 | 20 | print("#########################################\n") 21 | print(f"{home_team['triCode']} vs {away_team['triCode']}") 22 | print(f"SCORE: {home_team['score']} x {away_team['score']}") 23 | print(f"{clock} - {period['current']}\n") 24 | 25 | def get_teams_stats(): 26 | stats = get_links()["leagueTeamStatsLeaders"] 27 | data = get(BASE_URL+stats).json() 28 | teams = data["league"]["standard"]["regularSeason"]["teams"] 29 | 30 | teams = list(filter(lambda x: x["name"] != "Team", teams)) 31 | teams.sort(key = lambda x: int(x["ppg"]["rank"])) 32 | 33 | for team in teams: 34 | team_name = team["name"] 35 | nickname = team["nickname"] 36 | ppg_avg = team["ppg"]["avg"] 37 | rank = team["ppg"]["rank"] 38 | print(f"RANK: {rank} | {team_name} - {nickname} | PPG Médio: {ppg_avg}") 39 | 40 | 41 | 42 | while True: 43 | print("########################\n") 44 | print("SEJA BEM VINDO!!!! DADOS NBA IURYROSALTECH\n") 45 | print("1 - Ver Jogos\n") 46 | print("2 - Ver Times por PPG\n") 47 | user_choice = input("Opção: ") 48 | 49 | if user_choice == "1": 50 | get_currentScoreboard() 51 | elif user_choice == "2": 52 | get_teams_stats() 53 | else: 54 | continue -------------------------------------------------------------------------------- /level-b/12/__pycache__/convert_currency.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iuryrosal/projetos-python/45f9cf64bc7459bf1f28d36fd7556965e0633d09/level-b/12/__pycache__/convert_currency.cpython-38.pyc -------------------------------------------------------------------------------- /level-b/12/convert_currency.py: -------------------------------------------------------------------------------- 1 | from requests import get 2 | 3 | class ConvertCurrency: 4 | def __init__(self, api_key): 5 | self.url_base = "https://free.currconv.com" 6 | self.api_key = api_key 7 | self.currencies = self.get_currencies() 8 | 9 | def get_currencies(self): 10 | endpoint = f"/api/v7/currencies?apiKey={self.api_key}" 11 | url = self.url_base + endpoint 12 | data = get(url).json()["results"] 13 | data = list(data.values()) 14 | return data 15 | 16 | def show_currencies(self): 17 | for currency in self.currencies: 18 | name = currency.get("currencyName", "") 19 | _id = currency.get("id", "") 20 | symbol = currency.get("currencySymbol", "") 21 | print(f"{_id} | {name} | {symbol}") 22 | 23 | def transform_currency(self, initial_currency, amount, end_currency): 24 | endpoint = f"/api/v7/convert?q={initial_currency}_{end_currency}" 25 | parameters = ["&compact=ultra", f"&apiKey={self.api_key}"] 26 | url = self.url_base + endpoint +\ 27 | "".join([str(parameter) for parameter in parameters]) 28 | data = get(url).json() 29 | if len(data) == 0: 30 | print("Moedas Inválidas") 31 | return 32 | rate = data[f"{initial_currency}_{end_currency}"] 33 | try: 34 | amount = float(amount) 35 | except: 36 | print("Quantidade Inválida.") 37 | return 38 | new_value = rate*amount 39 | return new_value 40 | -------------------------------------------------------------------------------- /level-b/12/main.py: -------------------------------------------------------------------------------- 1 | from convert_currency import ConvertCurrency 2 | 3 | api_key = "" 4 | conv_curr = ConvertCurrency(api_key) 5 | conv_curr.show_currencies() 6 | print("\n") 7 | 8 | #Exemplo de Uso 9 | print(conv_curr.transform_currency("USD", 20, "BRL")) -------------------------------------------------------------------------------- /level-b/13/__pycache__/web_scraping.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iuryrosal/projetos-python/45f9cf64bc7459bf1f28d36fd7556965e0633d09/level-b/13/__pycache__/web_scraping.cpython-38.pyc -------------------------------------------------------------------------------- /level-b/13/main.py: -------------------------------------------------------------------------------- 1 | from web_scraping import WebScraping 2 | 3 | url = "https://www.airbnb.com.br/s/Fortaleza-~-CE/homes?tab_id=home_tab&refinement_paths%5B%5D=%2Fhomes&flexible_trip_dates%5B%5D=april&flexible_trip_dates%5B%5D=may&flexible_trip_lengths%5B%5D=weekend_trip&date_picker_type=calendar&query=Fortaleza%20-%20CE&place_id=ChIJL1zB9iFPxwcRqid5ywZnbf0&checkin=2022-05-09&checkout=2022-05-13&source=structured_search_input_header&search_type=autocomplete_click" 4 | web_scraping = WebScraping(url) 5 | print(web_scraping.pick_all_rooms()) -------------------------------------------------------------------------------- /level-b/13/web_scraping.py: -------------------------------------------------------------------------------- 1 | from bs4 import BeautifulSoup 2 | import requests 3 | 4 | class WebScraping: 5 | def __init__(self, url): 6 | self.url = url 7 | self.soup = self.__get_html() 8 | 9 | def __get_html(self): 10 | req = requests.get(self.url) 11 | soup = BeautifulSoup(req.content, "html.parser") 12 | return soup 13 | 14 | def __get_rooms(self): 15 | return self.soup.find_all("div", class_ = "_1e9w8hic") 16 | 17 | def __get_subtitle(self, room): 18 | return room.find("div", class_="mj1p6c8 dir dir-ltr").text 19 | 20 | def __get_title(self, room): 21 | return room.find("span", class_="ts5gl90 tl3qa0j t1nzedvd dir dir-ltr").text 22 | 23 | def __get_attrs(self, room): 24 | attr_room = {} 25 | details = room.find("div", class_="i1wgresd dir dir-ltr") 26 | attrs = details.find_all("span", class_="mp2hv9t dir dir-ltr") 27 | for attr in attrs: 28 | attr_info = attr.text.split() 29 | attr_room[f"{attr_info[1][:3]}"] = attr_info[0] 30 | return attr_room 31 | 32 | def __get_price(self, room_html): 33 | return room_html.find("div", class_ = "p1qe1cgb dir dir-ltr").find("span", class_ = "_tyxjp1").text[2:] 34 | 35 | def pick_all_rooms(self): 36 | list_of_rooms = [] 37 | for room in self.__get_rooms(): 38 | room_info = {} 39 | 40 | room_info["Title"] = self.__get_title(room) 41 | room_info["Subtitle"] = self.__get_subtitle(room) 42 | room_info["Price per Night (R$)"] = self.__get_price(room) 43 | attrs = self.__get_attrs(room) 44 | room_info["Guests"] = attrs.get("hós", None) 45 | room_info["Bedrooms"] = attrs.get("qua", None) 46 | room_info["Beds"] = attrs.get("cam", None) 47 | room_info["Bathrooms"] = attrs.get("ban", None) 48 | 49 | list_of_rooms.append(room_info) 50 | 51 | return list_of_rooms -------------------------------------------------------------------------------- /level-b/14/Logic_Gate.py: -------------------------------------------------------------------------------- 1 | class LogicGate: 2 | def __init__(self, gate_name): 3 | self.name = gate_name 4 | self.output = None 5 | 6 | def getName(self): 7 | return self.name 8 | 9 | def getOutput(self): 10 | self.output = self.performGateLogic() 11 | return self.output 12 | 13 | class BinaryGate(LogicGate): 14 | def __init__(self, gate_name): 15 | super().__init__(gate_name) 16 | self.pinA = None 17 | self.pinB = None 18 | 19 | def getPinA(self): 20 | if self.pinA == None: 21 | return self.putPinA() 22 | else: 23 | return self.pinA 24 | 25 | def getPinB(self): 26 | if self.pinB == None: 27 | return self.putPinB() 28 | else: 29 | return self.pinB 30 | 31 | def putPinA(self): 32 | return int(input("Digite a entrada do Pino A para a porta " + self.getName() + " : ")) 33 | 34 | def putPinB(self): 35 | return int(input("Digite a entrada do Pino B para a porta " + self.getName() + " : ")) 36 | 37 | class UnaryGate(LogicGate): 38 | def __init__(self, gate_name): 39 | super().__init__(gate_name) 40 | self.pinA = None 41 | 42 | def getPinA(self): 43 | if self.pinA == None: 44 | return self.putPinA() 45 | else: 46 | return self.pinA 47 | 48 | def putPinA(self): 49 | return int(input("Digite a entrada do Pino A para a porta " + self.getName() + " : ")) 50 | 51 | class ANDGate(BinaryGate): 52 | def __init__(self, gate_name): 53 | super().__init__(gate_name) 54 | 55 | def performGateLogic(self): 56 | a = self.getPinA() 57 | b = self.getPinB() 58 | 59 | if a == 1 and b == 1: 60 | return 1 61 | else: 62 | return 0 63 | 64 | class ORGate(BinaryGate): 65 | def __init__(self, gate_name): 66 | super().__init__(gate_name) 67 | 68 | def performGateLogic(self): 69 | a = self.getPinA() 70 | b = self.getPinB() 71 | 72 | if a == 1 or b == 1: 73 | return 1 74 | else: 75 | return 0 76 | 77 | class NOTGate(UnaryGate): 78 | def __init__(self, gate_name): 79 | super().__init__(gate_name) 80 | 81 | def performGateLogic(self): 82 | a = self.getPinA() 83 | 84 | if a == 1: 85 | return 0 86 | else: 87 | return 1 -------------------------------------------------------------------------------- /level-b/14/__pycache__/Logic_Gate.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iuryrosal/projetos-python/45f9cf64bc7459bf1f28d36fd7556965e0633d09/level-b/14/__pycache__/Logic_Gate.cpython-38.pyc -------------------------------------------------------------------------------- /level-b/14/diagram.plantuml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | class LogicGate 4 | class BinaryGate 5 | class UnaryGate 6 | class ANDGate 7 | class ORGate 8 | class NOTGate 9 | 10 | LogicGate -- BinaryGate 11 | LogicGate -- UnaryGate 12 | BinaryGate -- ANDGate 13 | BinaryGate -- ORGate 14 | UnaryGate -- NOTGate 15 | 16 | @enduml -------------------------------------------------------------------------------- /level-b/14/logics_gates_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iuryrosal/projetos-python/45f9cf64bc7459bf1f28d36fd7556965e0633d09/level-b/14/logics_gates_diagram.png -------------------------------------------------------------------------------- /level-b/14/main.py: -------------------------------------------------------------------------------- 1 | from Logic_Gate import * 2 | 3 | g1 = NOTGate("G1") 4 | print(g1.getOutput()) -------------------------------------------------------------------------------- /level-b/ReadMe.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Projetos em Python para Iniciantes 4 | 5 |

Projetos em Python para Iniciantes - Level B

6 |

7 | 8 | ## 🎯 Aprenda Python praticando com exemplos e projetos 9 | 10 | Abaixo você encontrará conteúdos para te guiar e ajudar a aprender Python, praticando por meio da construção de mini-projetos e exemplos práticos. 11 | 12 | Segue nas redes sociais para acompanhar mais conteúdo:
13 | [](https://github.com/iuryrosal) 14 | [](https://www.linkedin.com/in/iuryrosal/) 15 | [](https://www.youtube.com/channel/UC0bUO0t7Hv7vTBCxUecj_aw) 16 |
17 | 18 | ## 😄 Level-B 19 | 20 | > 😏 Level B: Projetos desse nível já envolvem conhecimentos um pouco mais intermediários para quem está começando. Normalmente trabalhamos com alguns paradigmas de programação como Programação Orientada a Objetos. 21 | 22 | | ID | Projeto | Vídeo | Repositório | 23 | |----|---------|-------|-------------| 24 | | 09 | Filtrando e Mapeando Animais de um Aquário |[][video_09]|[][repo_09]| 25 | | 10 | Map e Reduce em Aquário|[][video_10]|[][repo_10]| 26 | | 11 | Coletando e Exibindo Dados do NBA com API|[][video_11]|[][repo_11]| 27 | | 12 | Conversor de Moedas Orientado a Objetos|[][video_12]|[][repo_12]| 28 | | 13 | Conversor de Moedas Orientado a Objetos|[][video_13]|[][repo_13]| 29 | | 14 | Portas Lógicas e Herança |[][video_13]|[][repo_13]| 30 | 31 | 32 | [video_01]:https://www.youtube.com/watch?v=MRYlWPrsMYk&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 33 | [video_02]:https://www.youtube.com/watch?v=x0_mWMQLz3E&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 34 | [video_03]:https://www.youtube.com/watch?v=kO_lUkeQm4c&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 35 | [video_04]:https://www.youtube.com/watch?v=yfAixrxCVfo&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 36 | [video_05]:https://www.youtube.com/watch?v=aAImiFpG_hA&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 37 | [video_06]:https://www.youtube.com/watch?v=ridIE7ZS5KI&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 38 | [video_07]:https://www.youtube.com/watch?v=m8xBpg0knCM&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 39 | [video_08]:https://www.youtube.com/watch?v=66ugH75ao7c&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 40 | [video_09]:https://www.youtube.com/watch?v=0PvfcHCtqXw&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 41 | [video_10]:https://www.youtube.com/watch?v=yZ2ATIGXSIQ&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 42 | [video_11]:https://www.youtube.com/watch?v=ghOaY1sd9aY&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 43 | [video_12]:https://www.youtube.com/watch?v=9BwJKlLu9Ug&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 44 | [video_13]:https://www.youtube.com/watch?v=YEvoDf2azq0&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 45 | [video_14]:https://www.youtube.com/watch?v=_iCCE_VuO4g&list=PLshkB4NQEfC7jz8Ig-JcqwjZz8WSI2s8W 46 | 47 | [repo_01]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/01 48 | [repo_02]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/02 49 | [repo_03]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/03 50 | [repo_04]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/04 51 | [repo_05]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/05 52 | [repo_06]:https://github.com/iuryrosal/projetos-python/tree/main/level-a/06 53 | [repo_07]:https://github.com/iuryrosal/projetos-python/tree/main/level-a/07 54 | [repo_08]:https://github.com/iuryrosal/projetos-python/blob/main/level-a/08 55 | [repo_09]:https://github.com/iuryrosal/projetos-python/tree/main/level-b/09 56 | [repo_10]:https://github.com/iuryrosal/projetos-python/tree/main/level-b/10 57 | [repo_11]:https://github.com/iuryrosal/projetos-python/blob/main/level-b/11 58 | [repo_12]:https://github.com/iuryrosal/projetos-python/blob/main/level-b/12 59 | [repo_13]:https://github.com/iuryrosal/projetos-python/blob/main/level-b/13 60 | [repo_14]:https://github.com/iuryrosal/projetos-python/blob/main/level-b/14 -------------------------------------------------------------------------------- /level-c/16/esquematizacao_fac.plantuml: -------------------------------------------------------------------------------- 1 | @startuml 2 | interface Transport { 3 | +deliver() 4 | } 5 | 6 | class Truck { 7 | +name 8 | +category 9 | +deliver() 10 | } 11 | 12 | class Ship { 13 | +String name 14 | +String category 15 | +deliver() 16 | } 17 | 18 | class Logistics { 19 | +createTransport() 20 | +planDelivery() 21 | } 22 | 23 | class RoadLogistics { 24 | +String name 25 | +createTransport() 26 | } 27 | 28 | class SeaLogistics { 29 | +String name 30 | +createTransport() 31 | } 32 | 33 | Logistics --> RoadLogistics 34 | Logistics --> SeaLogistics 35 | Transport --> Truck 36 | Transport --> Ship 37 | Logistics --- Transport 38 | 39 | 40 | @enduml -------------------------------------------------------------------------------- /level-c/16/esquematizacao_prob.plantuml: -------------------------------------------------------------------------------- 1 | @startuml 2 | class Truck { 3 | +String name 4 | +planDelivery() 5 | } 6 | Truck <|-- Application 7 | @enduml -------------------------------------------------------------------------------- /level-c/16/factory_method.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | 3 | class Logistics: 4 | def createTransport(self): 5 | pass 6 | 7 | def planDelivery(self): 8 | transport = self.createTransport() 9 | 10 | result = f"Logistics: Transporte sendo preparado...\n{transport.deliver()}" 11 | 12 | return result 13 | 14 | class RoadLogistics(Logistics): 15 | def __init__(self, name): 16 | self.name = name 17 | 18 | def createTransport(self): 19 | return Truck(self.name) 20 | 21 | class SeaLogistics(Logistics): 22 | def __init__(self, name): 23 | self.name = name 24 | 25 | def createTransport(self): 26 | return Ship(self.name) 27 | 28 | class Transport(ABC): 29 | @abstractmethod 30 | def deliver(self): 31 | pass 32 | 33 | class Truck(Transport): 34 | def __init__(self, name): 35 | self.name = name 36 | self.category = "truck" 37 | 38 | def deliver(self): 39 | result = (f"{self.category} preparado para entrega: {self.name}", 40 | "Transporte térreo....") 41 | return result 42 | 43 | class Ship(Transport): 44 | def __init__(self, name): 45 | self.name = name 46 | self.category = "ship" 47 | 48 | def deliver(self): 49 | result = (f"{self.category} preparado para entrega: {self.name}", 50 | "Transporte marítimo....") 51 | return result 52 | 53 | def client_code(logistics: Logistics): 54 | print(f"App: Carregado com {logistics.__class__.__name__}.", 55 | f"{logistics.planDelivery()}") 56 | 57 | if __name__ == "__main__": 58 | client_code(RoadLogistics("Caminhao1")) 59 | print("\n") 60 | client_code(SeaLogistics("Navio1")) -------------------------------------------------------------------------------- /level-c/17/abstract_factory.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | 3 | class AbstractApiFortal(ABC): 4 | def __init__(self, token): 5 | self.token = token 6 | 7 | @abstractmethod 8 | def collect_data(self): 9 | pass 10 | 11 | class ApiFortalTransport(AbstractApiFortal): 12 | def collect_data(self): 13 | return f"Dados Coletados ApiFortalTransport por meio do token: {self.token}" 14 | 15 | class ApiFortalSecurity(AbstractApiFortal): 16 | def collect_data(self): 17 | return f"Dados Coletados ApiFortalSecurity por meio do token: {self.token}" 18 | 19 | class AbstractApiCe(ABC): 20 | def __init__(self, token): 21 | self.token = token 22 | 23 | @abstractmethod 24 | def collect_data(self): 25 | pass 26 | 27 | @abstractmethod 28 | def collect_data_by_city(self, city): 29 | pass 30 | 31 | class ApiCeTransport(AbstractApiCe): 32 | def collect_data(self): 33 | return f"Dados Coletados ApiCeTransport por meio do token: {self.token}" 34 | 35 | def collect_data_by_city(self, city): 36 | return f"Dados Coletados da cidade {city} ApiCeTransport por meio do token: {self.token}" 37 | 38 | class ApiCeSecurity(AbstractApiCe): 39 | def collect_data(self): 40 | return f"Dados Coletados ApiCeSecurity por meio do token: {self.token}" 41 | 42 | def collect_data_by_city(self, city): 43 | return f"Dados Coletados da cidade {city} ApiCeSecurity por meio do token: {self.token}" 44 | 45 | class AbstractAPIFactory(ABC): 46 | def __init__(self, token_fortal, token_ce): 47 | self.token_fortal = token_fortal 48 | self.token_ce = token_ce 49 | 50 | @abstractmethod 51 | def create_api_fortal(self): 52 | pass 53 | 54 | @abstractmethod 55 | def create_api_ce(self): 56 | pass 57 | 58 | class TransportDataFactory(AbstractAPIFactory): 59 | def create_api_fortal(self): 60 | return ApiFortalTransport(self.token_fortal) 61 | 62 | def create_api_ce(self): 63 | return ApiCeTransport(self.token_ce) 64 | 65 | class SecurityDataFactory(AbstractAPIFactory): 66 | def create_api_fortal(self): 67 | return ApiFortalSecurity(self.token_fortal) 68 | 69 | def create_api_ce(self): 70 | return ApiCeSecurity(self.token_ce) 71 | 72 | def client_code(factory: AbstractAPIFactory): 73 | product_fortal = factory.create_api_fortal() 74 | product_ce = factory.create_api_ce() 75 | 76 | print(product_fortal.collect_data()) 77 | print(product_ce.collect_data_by_city("Iguatu")) 78 | 79 | if __name__ == "__main__": 80 | token_ce = "ce12345" 81 | token_fortal = "fortal54321" 82 | 83 | print("Coletando dados de Transporte") 84 | client_code(TransportDataFactory(token_fortal, token_ce)) 85 | 86 | print("Coletando dados de Segurança") 87 | client_code(SecurityDataFactory(token_fortal, token_ce)) 88 | 89 | -------------------------------------------------------------------------------- /level-c/17/esquematizacao_prob.plantuml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | class APICe { 4 | +String token 5 | +collect_data_transport() 6 | +collect_data_transport_by_city(city) 7 | +collect_data_security() 8 | +collect_data_security_by_city(city) 9 | } 10 | 11 | class APIFortal { 12 | +String token 13 | +collect_data_transport() 14 | +collect_data_security() 15 | } 16 | 17 | @enduml -------------------------------------------------------------------------------- /level-c/17/esquematizacao_sol.plantuml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | interface AbstractApiFortal{ 4 | +String token 5 | +collect_data() 6 | } 7 | 8 | class ApiFortalTransport { 9 | +collect_data() 10 | } 11 | 12 | class ApiFortalSecurity { 13 | +collect_data() 14 | } 15 | 16 | interface AbstractApiCe{ 17 | +String token 18 | +collect_data() 19 | +collect_data_by_city(city) 20 | } 21 | 22 | class ApiCeTransport { 23 | +collect_data() 24 | +collect_data_by_city(city) 25 | } 26 | 27 | class ApiCeSecurity { 28 | +collect_data() 29 | +collect_data_by_city(city) 30 | } 31 | 32 | interface AbstractAPIFactory{ 33 | +String token_ce 34 | +String token_fortal 35 | +create_api_fortal() 36 | +create_api_ce() 37 | } 38 | 39 | class TransportDataFactory { 40 | +create_api_fortal() : ApiFortalTransport 41 | +create_api_ce() : ApiCeTransport 42 | } 43 | 44 | class SecurityDataFactory { 45 | +create_api_fortal() : ApiFortalSecurity 46 | +create_api_ce() : ApiCeSecurity 47 | } 48 | 49 | class App { 50 | 51 | } 52 | 53 | AbstractAPIFactory --> TransportDataFactory 54 | AbstractAPIFactory --> SecurityDataFactory 55 | 56 | AbstractApiFortal --> ApiFortalTransport 57 | AbstractApiFortal --> ApiFortalSecurity 58 | 59 | AbstractApiCe --> ApiCeTransport 60 | AbstractApiCe --> ApiCeSecurity 61 | 62 | App --> AbstractAPIFactory 63 | TransportDataFactory --> ApiFortalTransport 64 | TransportDataFactory --> ApiCeTransport 65 | 66 | SecurityDataFactory --> ApiFortalSecurity 67 | SecurityDataFactory --> ApiCeSecurity 68 | 69 | @enduml -------------------------------------------------------------------------------- /level-c/18/entrada_usuario.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Iury Rosal", 3 | "origem": "Linkedin", 4 | "permissao": "FOLLOWERS", 5 | "data_inicio": "2021-12-31", 6 | "data_fim": "2021-01-01", 7 | "filter": { 8 | "Title_Contain": "Dados", 9 | "Quant_Exp": ">3" 10 | } 11 | } -------------------------------------------------------------------------------- /level-c/18/modulo.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | 3 | class RequisicaoAPILinkedin: 4 | def __init__(self) -> None: 5 | self.req = {} 6 | 7 | class RequisicaoAPIInstagram: 8 | def __init__(self) -> None: 9 | self.req = {} 10 | 11 | class BuilderReq(ABC): 12 | @abstractmethod 13 | def reset(): 14 | pass 15 | 16 | @abstractmethod 17 | def setQueryParams(filters): 18 | pass 19 | 20 | @abstractmethod 21 | def setDateRange(date_start, date_end): 22 | pass 23 | 24 | @abstractmethod 25 | def setPermission(permission): 26 | pass 27 | 28 | @abstractmethod 29 | def setEndpoint(): 30 | pass 31 | 32 | @abstractmethod 33 | def getRequest(): 34 | pass 35 | 36 | class BuilderReqLinkedin(BuilderReq): 37 | def __init__(self) -> None: 38 | self.reqAPI = self.reset() 39 | 40 | def reset(self): 41 | return RequisicaoAPILinkedin() 42 | 43 | def setQueryParams(self, filters): 44 | query_params = "" 45 | for filter_, value in filters.items(): 46 | query_params += f"&{filter_}={value}" 47 | self.reqAPI.req["QueryParams"] = query_params 48 | 49 | def setDateRange(self, date_start, date_end): 50 | self.reqAPI.req["DateRange"] = f"DateStart={date_start}&DateEnd={date_end}" 51 | 52 | def setPermission(self, permission): 53 | self.reqAPI.req["Permission"] = f"/{permission}/" 54 | 55 | def setEndpoint(self): 56 | link = "https://www.linkedin.com/company/86297503/api" 57 | self.reqAPI.req["endpoint"] = link + self.reqAPI.req["Permission"] + self.reqAPI.req["DateRange"] + self.reqAPI.req["QueryParams"] 58 | 59 | def getRequest(self): 60 | return self.reqAPI.req 61 | 62 | class BuilderReqInstagram(BuilderReq): 63 | def __init__(self) -> None: 64 | self.reqAPI = self.reset() 65 | 66 | def reset(self): 67 | return RequisicaoAPIInstagram() 68 | 69 | def setQueryParams(self, filters): 70 | query_params = "" 71 | for filter_, value in filters.items(): 72 | query_params += f"&{filter_}={value}" 73 | self.reqAPI.req["QueryParams"] = query_params 74 | 75 | def setDateRange(self, date_start, date_end): 76 | self.reqAPI.req["DateRange"] = f"Date_In={date_start}&Date_End={date_end}" 77 | 78 | def setPermission(self, permission): 79 | self.reqAPI.req["Permission"] = f"/{permission}/" 80 | 81 | def setEndpoint(self): 82 | link = "https://www.instagram.com/account/86297503/api/" 83 | self.reqAPI.req["endpoint"] = link + self.reqAPI.req["Permission"] + self.reqAPI.req["DateRange"] + self.reqAPI.req["QueryParams"] 84 | 85 | def getRequest(self): 86 | return self.reqAPI.req 87 | 88 | class Director: 89 | def __init__(self, request) -> None: 90 | self.request_user = request 91 | 92 | def ConstructReqLinkedin(self, builder): 93 | builder.reset() 94 | builder.setQueryParams(self.request_user["filter"]) 95 | builder.setDateRange(self.request_user["data_inicio"], self.request_user["data_fim"]) 96 | builder.setPermission(self.request_user["permissao"]) 97 | builder.setEndpoint() 98 | 99 | def ConstructReqInstagram(self, builder): 100 | builder.reset() 101 | builder.setQueryParams(self.request_user["filter"]) 102 | builder.setDateRange(self.request_user["data_inicio"], self.request_user["data_fim"]) 103 | builder.setPermission(self.request_user["permissao"]) 104 | builder.setEndpoint() 105 | 106 | 107 | if __name__ == "__main__": 108 | input_user = { 109 | "name": "Iury Rosal", 110 | "origem": "Linkedin", 111 | "permissao": "FOLLOWERS", 112 | "data_inicio": "2021-12-31", 113 | "data_fim": "2021-01-01", 114 | "filter": { 115 | "Title_Contain": "Dados", 116 | "Quant_Exp": ">3" 117 | } 118 | } 119 | 120 | director = Director(input_user) 121 | 122 | if input_user["origem"] == "Linkedin": 123 | builder = BuilderReqLinkedin() 124 | director.ConstructReqLinkedin(builder) 125 | request = builder.getRequest() 126 | elif input_user["origem"] == "Instagram": 127 | builder = BuilderReqInstagram() 128 | director.ConstructReqInstagram(builder) 129 | request = builder.getRequest() 130 | else: 131 | print("Origem desconhecida!") 132 | print(request) -------------------------------------------------------------------------------- /level-c/18/saida_req_instagram.json: -------------------------------------------------------------------------------- 1 | { 2 | "QueryParam": "&Title_Contain=Dados&Quant_Exp=>3", 3 | "DateRange": "Date_In=2021-12-31&Date_End=2021-01-01", 4 | "Permission": "/FOLLOWERS/", 5 | "Endpoint": "https://www.instagram.com/account/86297503/api/Date_In=2021-12-31&Date_End=2021-01-01&Title_Contain=Dados&Quant_Exp=>3" 6 | } -------------------------------------------------------------------------------- /level-c/18/saida_req_linkedin.json: -------------------------------------------------------------------------------- 1 | { 2 | "QueryParam": "&Title_Contain=Dados&Quant_Exp=>3", 3 | "DateRange": "DateStart=2021-12-31&DateEnd=2021-01-01", 4 | "Permission": "/FOLLOWERS/", 5 | "Endpoint": "https://www.linkedin.com/company/86297503/api/FOLLOWERS/DateStart=2021-12-31&DateEnd=2021-01-01&Title_Contain=Dados&Quant_Exp=>3" 6 | } -------------------------------------------------------------------------------- /level-c/19/__pycache__/database.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iuryrosal/projetos-python/45f9cf64bc7459bf1f28d36fd7556965e0633d09/level-c/19/__pycache__/database.cpython-38.pyc -------------------------------------------------------------------------------- /level-c/19/client.py: -------------------------------------------------------------------------------- 1 | from database import DatabaseClient 2 | 3 | database_1 = DatabaseClient(1234) 4 | database_2 = DatabaseClient(4567) 5 | 6 | print(database_1.get_connection()) 7 | 8 | print(database_2.get_connection()) 9 | 10 | if database_1 == database_2: 11 | print("São iguais!") 12 | else: 13 | print("São distintas!") 14 | 15 | database_1.set_classmates(["Iury"]) 16 | print(database_1.get_classmates()) 17 | 18 | database_2.set_classmates(["Laura"]) 19 | print(database_2.get_classmates()) 20 | print(database_1.get_classmates()) -------------------------------------------------------------------------------- /level-c/19/client_without_singleton.py: -------------------------------------------------------------------------------- 1 | class DatabaseClient: 2 | classmates = [] 3 | connection = 0 4 | 5 | def __init__(self, port) -> None: 6 | self.set_connection(port) 7 | 8 | def set_connection(self, port): 9 | self.connection = port 10 | 11 | def get_connection(self): 12 | return self.connection 13 | 14 | def set_classmates(self, classmates): 15 | for classmate in classmates: 16 | self.classmates.append(classmate) 17 | 18 | def get_classmates(self): 19 | return self.classmates 20 | 21 | if __name__ == "__main__": 22 | database_1 = DatabaseClient(1234) 23 | database_2 = DatabaseClient(4567) 24 | 25 | print(database_1.get_connection()) 26 | 27 | print(database_2.get_connection()) 28 | 29 | if database_1 == database_2: 30 | print("São iguais!") 31 | else: 32 | print("São distintas!") 33 | 34 | database_1.set_classmates(["Iury"]) 35 | print(database_1.get_classmates()) 36 | 37 | database_2.set_classmates(["Laura"]) 38 | print(database_2.get_classmates()) 39 | print(database_1.get_classmates()) -------------------------------------------------------------------------------- /level-c/19/database.py: -------------------------------------------------------------------------------- 1 | class DatabaseSingleton(type): 2 | _instances = {} 3 | 4 | def __call__(cls, *args, **kwds): 5 | if cls not in cls._instances: 6 | instance = super().__call__(*args, **kwds) 7 | cls._instances[cls] = instance 8 | return cls._instances[cls] 9 | 10 | 11 | class DatabaseClient(metaclass=DatabaseSingleton): 12 | classmates = [] 13 | connection = 0 14 | 15 | def __init__(self, port) -> None: 16 | self.set_connection(port) 17 | 18 | def set_connection(self, port): 19 | self.connection = port 20 | 21 | def get_connection(self): 22 | return self.connection 23 | 24 | def set_classmates(self, classmates): 25 | for classmate in classmates: 26 | self.classmates.append(classmate) 27 | 28 | def get_classmates(self): 29 | return self.classmates -------------------------------------------------------------------------------- /level-c/20/__pycache__/adapter.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iuryrosal/projetos-python/45f9cf64bc7459bf1f28d36fd7556965e0633d09/level-c/20/__pycache__/adapter.cpython-311.pyc -------------------------------------------------------------------------------- /level-c/20/__pycache__/client_code.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iuryrosal/projetos-python/45f9cf64bc7459bf1f28d36fd7556965e0633d09/level-c/20/__pycache__/client_code.cpython-311.pyc -------------------------------------------------------------------------------- /level-c/20/__pycache__/data.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iuryrosal/projetos-python/45f9cf64bc7459bf1f28d36fd7556965e0633d09/level-c/20/__pycache__/data.cpython-311.pyc -------------------------------------------------------------------------------- /level-c/20/__pycache__/data_2.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iuryrosal/projetos-python/45f9cf64bc7459bf1f28d36fd7556965e0633d09/level-c/20/__pycache__/data_2.cpython-311.pyc -------------------------------------------------------------------------------- /level-c/20/__pycache__/data_dict.cpython-311.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iuryrosal/projetos-python/45f9cf64bc7459bf1f28d36fd7556965e0633d09/level-c/20/__pycache__/data_dict.cpython-311.pyc -------------------------------------------------------------------------------- /level-c/20/adapter.py: -------------------------------------------------------------------------------- 1 | from data_dict import DataDict 2 | from data_list import DataList 3 | 4 | class AdapterListToDict(DataDict, DataList): 5 | def __init__(self) -> None: 6 | DataDict.__init__(self) 7 | DataList.__init__(self) 8 | 9 | def get_clients(self): 10 | database = {} 11 | id_ = 0 12 | for item in self.get_clients_list(): 13 | database[f"{id_}"] = item 14 | id_ += 1 15 | return database -------------------------------------------------------------------------------- /level-c/20/client_code.py: -------------------------------------------------------------------------------- 1 | from data_dict import DataDict 2 | 3 | def client_code(data: DataDict): 4 | print(data.get_clients()) -------------------------------------------------------------------------------- /level-c/20/data_dict.py: -------------------------------------------------------------------------------- 1 | class DataDict: 2 | def __init__(self) -> None: 3 | self.database = { 4 | "0": "Iury", 5 | "1": "Davi", 6 | "2": "Vinicius" 7 | } 8 | 9 | def get_clients(self): 10 | return self.database -------------------------------------------------------------------------------- /level-c/20/data_list.py: -------------------------------------------------------------------------------- 1 | class DataList: 2 | def __init__(self) -> None: 3 | self.data_list = ["Helena", "Michel", "Andressa"] 4 | 5 | def get_clients_list(self): 6 | return self.data_list -------------------------------------------------------------------------------- /level-c/20/esquematizacao_prob.plantuml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | class ClientCode { 4 | + client_code(data) 5 | } 6 | 7 | class DataDict { 8 | + get_clients() 9 | } 10 | 11 | class DataList { 12 | + get_list_clients() 13 | } 14 | 15 | class Adapter { 16 | + method(data) 17 | } 18 | 19 | ClientCode o-- DataDict 20 | DataList <|-- Adapter 21 | DataDict <|-- Adapter 22 | ClientCode o-- Adapter 23 | @enduml -------------------------------------------------------------------------------- /level-c/20/main.py: -------------------------------------------------------------------------------- 1 | from client_code import client_code 2 | from data_dict import DataDict 3 | from data_list import DataList 4 | from adapter import AdapterListToDict 5 | 6 | data = DataDict() 7 | client_code(data) 8 | 9 | data_list = DataList() 10 | print(data_list.get_clients_list()) 11 | 12 | adapter = AdapterListToDict() 13 | client_code(adapter) 14 | 15 | --------------------------------------------------------------------------------