Thank you for getting to this point. This repository was created for a project to learn Python. "2022 Complete Python Bootcamp From Zero to Hero in Python " from UDEMY.
Quick note: The trainer (Jose Portilla) uses Anaconda, Jupyter Notebooks. I tried to follow along using VSCode.
- Section 1: Course Overview
- Section 2: Python Setup
- Section 3: Python Object and Data Structure Basics
- Section 4: Python Comparison Operators
- Section 5: Python Statements
- Section 6: Methods and Functions
- Section 7: Milestone Project - 1
- Section 8: Object Oriented Programming
- Section 9: Modules and Packages
- Section 10: Errors and Exception Handling
- Section 11: Milestone Project - 2
- Section 12: Python Decorators
- Section 13: Python Generators
- Section 14: Advanced Python Modules
- Section 15: Web-Scraping
- Section 16: Working-with-Images
- Section 17: PDFs-and-Spreadsheets
- Section 18: Emailing-with-Python
- Section 19: Advanced Python Objects and Data Structures
- Section 20: Milestone Project - 3
- Section 21: Bonus Material - Introduction to G
- Installed VS Code.
- Installed Python.
- Installed several plugins from within VSCode related to Python.+
Prerequisites:
- Python
- Press Start > Write
environment
> ClickEdit the system variables environment
- Click Environment Variables
- Under System variables, click New
- Variable Name = python
- Variable Value = C:\Users\Ivan\AppData\Local\Programs\Python\Python310\
- Ok > Ok
- CLI Basics (Windows)
- Upgraded current python installation:
py -3 -m pip install --upgrade pip
- When to choose a list or dictionary?
- Dictionary is OK when, for example, quickly wanting a value without needing to know its exact location--cons is that can't be sorted, sliced.
- Logical operators - Chain operators
- and or not
- Ex: 1 < 2 and 2 < 3
- *args to pass N values into a function in a tuple format
- **kwargs (keywords arguments) to create a dictionary based on the values sent to a function
- LEGB Rule
- L: Local — Names assigned in any way within a function (def or lambda), and not declared global in that function.
- E: Enclosing function locals — Names in the local scope of any and all enclosing functions (def or lambda), from inner to outer.
- G: Global (module) — Names assigned at the top-level of a module file, or declared global in a def within the file.
- B: Built-in (Python) — Names preassigned in the built-in names module : open, range, SyntaxError,...
- Allows users to create their own objects.
- Allows us to create code that is repeatable and organized.
- Camel Casing for classes
- Syntax sample:
- def when is inside of a class is called a method.
- init is a special type that is always called when creating an instance of the class
- self keyword connects the method to the instance of the class
class NameOfClass():
def __init__(self, param1, param2):
self.param1 = param1
self.param2 = param2
def some_method(self):
#perform some action
print(self.param1)
- Packages is a collection of modules
- Modules are scripts that you can call from a different .py files.
- init identifies a folder that should be a package or subpackage
if __name__=="__main__":
- original file or actual import- Code organization
- Keywords
- try: attempt
- except: execute if error
- finally:
- pylint
- unittest
pylint myexample.py -r y
- PEP 8
- On/Off Switch for functions
- @ operators is used and located above the function
- we can pass functions as arguments
- Generate a sequence of values over time
- usage of a yield statement
- range()
- Memory efficiency
- Collections (from collections import...)
- d = defaultdict(lambda: 0) -- assign default value to dictionary
- named tuple
- OS
- os.unlink(path) - delete a file
- os.rmdir(path) - deletes a folder
- shutil.rmtree(path) - remove all files and folders contained int he path
- Better method: send2trash
- Math and Random
- Debugger
- pdb.set_trace()
- Timeit
- Regular Expressions
- Unzipping and Zip
- Automate the gathering of data from the web
- Libraries
- pip install requests
- pip install lxml
- pip install bs4
- Sample:
result = requests.get("http://example.com/") soup = bs4.BeautifulSoup(result.text,"lxml") print(soup.select('p'))
- Return tags. To remove
soup.select('title')[0].getText()
pip install pillow
- Image.open
- .rotate
- .save
- .paste
- Pandas
- Openpyxl
- Google Sheet Python API
pip install PyPDF2
import smtplib
import imaplib