Complete Python Developer in 2020: Zero to Mastery Created by Andrei Neagoie
- Course Outline
- Join Our Online Classroom!
- Discord Community
- Source code (human readable)
- => interpreter: goes line by line and executes it consecutively
- => or compiler: takes code all at once, reads the entire file and then translates that to machine code.
- cypthon VM (virtual machine)
- Terminal
- Code Editors: sublime text, visual studio code
- IDEs: PyCharm, Spyder
- Notebooks: jupyter
python3
exit()
python main.py
- Python3 introduced in 2008
- The Story of Python
- Python 2 vs Python 3
- Another Article
- Languages have tradeoffs, so choose depending on purpose
- Python is great for developer code
- Terms
- Data Types
- Actions
- Best Practices
- Numbers
- Math Functions
- Learn a language by using it not by memorizing it.
- Python Keywords
- Best Practices
- snake_case
- start with lowercase or underscore
- letters, numbers, underscores
- case sensitive
- don't overwrite keywords
- CONSTANTS are CAPITALIZED
- expressions: pieces of code that produce a value (right side of equation)
- statements: entire lines of code that perform an action
- e.g.,
+=
,*=
\
to make next char a string\t
for a tab\n
for a new line
- f string
(f ...)
- recommended .format()
still used from Python 2
- access different parts of a string by its index
- once created, you cannot reassign part of a string
- ordered sequence of objects
- like arrays in other languages
- List Slicing
- Lists are mutable
- copying vs modifying
- an array with another array inside it [multi-dimensional]
- Also known as mappings or hash tables. They are key value pairs that DO NOT retain order
dict
data type
- has to be immutable (a
list
cannot be a key because it can change) - has to be unique, a repeated key will be overwritten
- immutable lists: e.g., children = ('Omi', 'SungOh')
- Tuple Methods
count()
index()
- unordered collection of unique elements (no duplicates)
- Python Set Methods
- if
- elif
- else
condition_if_true if condition else condition_if_false
- and, or, >, <, ==, !=, not, and not, etc.
- list
- dictionary
- tuple
- set
- string
- clean
- readable
- predictable
- DRY - don't repeat yourself
def
define a function- should do one thing really well
- should return something
- parameters define variables to pass into a function
- arguments are called (invoked) when running a function
- assign a default parameter
- can use keyword arguments to explicitly define the values rather than positional arguments
- functions should
return
something
.method
has to be owned by something to the left of the period
def test(a)
'''
Info: this function tests and prints param a
'''
print()
test('!!!')
- Rule order: params, *args, default parameters, **kwargs
- start with local
- Parent of local?
- Global
- Built in Python functions'
nonlocal
used to refer to the parent local- generally write clean code and don't use these keywords
- garbage collection
- Code Editors: lightweight as they provide editors and linting
- IDEs are full-fledged environments
- Tools
- Code Editors
- Sublime Text
- Visual Studio Code
- IDEs
- PyCharm
- Spyder
- Notebooks
- jupyter
- Code Editors
- a paradigm for structuring and writing our code
- modeling our code in terms of real world objects
- CLASS => instantiate instances
class CamelCase:
- the binding of data and functions that manipulate that data into one big object to keep everything in this box for interaction
- hiding information and giving access to only what's necessary
- no true private variables in Python
- but convention to use underscore
_variable
to indicate it shouldn't be touched
- allows new objects to take on the characteristics of existing objects
- object classes can share the same method name but those method names can act differently based on what object calls them
- introspection: the ability to determine the type of an object at runtime.
- special methods that Python recognizes to modify our classes
- Dunder Methods
MRO - Method Resolution Order
- not recommended way to code
- focus on separation of concerns
- separate data and functions
- Goals the same regardless:
- Clear and Understandable
- Easy to Extend
- Easy to Maintain
- Memory Efficient
- DRY
- separation between the data of a program and its behavior
- Rules:
- Given the same input it will always return the same output
- It should not produce any side effects
map(), filter(), zip(), reduce()
- one-time anonymous functions
- reduces length of code but makes it less readable
@classmethod
@staticmethod
- a function that accepts another function in its parameters or returns another function
- supercharges our functions
- a function that wraps another function and enhances it or changes it
- e.g.,
range()
usesyield
keyword to pause and resume functions - generators are a subset of iterables
- Modules: file_name.py
- Packages: folders that require an init.py file
__name__
if __name__ == '__main__':
- Built-in Modules: Python Module Index
- import only what you need: e.g.,
from random import shuffle
- Python Package Index
- e.g., search for 'read csv python3 built-in'
- pip install PIP
- virtual environments venv
- Useful Modules
- Specialized Data Types
- list vs array
- linting
- IDE or Text Editor
- Read errors
- Python Debugger or pdb (can also test inside pdb)
import pdb
def add(num1, num2):
pdb.set_trace()
return num1 + num2
print(add(4, 5))
open
- Python uses a cursor to read a file
- Read, Write, and Append (mode='r')
- File Paths pathlib
- File I/O Errors
- Python RegEx
- regular expressions 101
- Interactive RegEx RegexOne
-
Tools
- pylint
- pyflakes
- AutoPEP 8
-
Unit Tests
- run all tests (-v for verbose):
python -m unittest -v
- run all tests (-v for verbose):
- Software Engineer
- Python developer
- Data Scientist
- Data Analyst
- Research Analyst
- Backend Developer
- Testing/Automation
- Machine Learning
- Pillow forked from PIL
- Python Imaging Library
- JPG to PNG Pokedex Converter
- OpenCV
- OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in commercial products.
- PDF Merger
- PDF Watermarker
- How Hackers Work
- Password API
- Twitter API
- Tweepy
- Twilio
- Your new Phone Number is +16102981505
- Big List of Web Scraping Uses: Application of Web Scraping to Business
- Web Scraping and APIs
/robots.txt
e.g., https://www.airbnb.com/robots.txt to check what the site allows you to scrape
- How Googlebot Works
- Beautiful Soup Documentation
- CSS Selectors
- Data Pretty Printer
- Scrapy - Web Scraping Framework
- How Websites Work
- Setting Up Flask
- venv documentation
- Python Virtual Environments
- Where in a virtualenv does the custom code go?
- Flask Quickstart
$ export FLASK_APP=hello.py
$ flask run
* Running on http://127.0.0.1:5000/
- Flask Templates
- Flask Static Files
- Flask Favicon
- Create dynamic URLs in Flask with url_for()
- Jinja (template engine)
- Variable Rules
- MIME Types
- Mashup Templates
- cruip
- Creative Tim
- hatchful - create stunning logos in seconds
- AI, Machine Learning, Deep Learning, Data Science
- Machine Learning:
- given input and output, the computer creates the function to manifest the desired output
- functions, algorithms, models, brains, bots
- given input and output, the computer creates the function to manifest the desired output
- History of Data
- spreadsheets
- Relational DB
- "Big Data" NoSQL e.g., mongoDB
- Machine Learning
- Types of Machine Learning
- Supervised
- Classification: e.g., apples or pears
- Regression: e.g., track stock market prices
- Unsupervised
- Clustering: creating groups out of data points
- Association Rule Learning: associate different things to make predictions (as to what a customer might buy in the future)
- Reinforcement
- skill acquisition
- real time learning
- Supervised
- Import the data - from kaggle.com
- Clean the data - pandas
- Split the data: training set, test set (80/20)
- Create a Model
- Check the output
- Improve
- Nearest Neighbors
- K-Nearest Neighbors Demo
- K-Nearest Neighbors Algorithm
- Model Persistence
Finished course on Saturday, February 1, 2020