Modern Python 3 Bootcamp Review
Introduction to Python
Teacher
- Colt
About this Course
Learn how to make better decisions with data in this course on data analysis. We’ll start by looking at what data analysis is, and then we’ll see how we can use data analysis to create better outcomes.
Notes
General
Python2 vs Python3 - Python3 was a major overhaul and not all functions etc will be backward compatible. Python2 will be retired eventually, no longer maintained
Boolean ‘1’ is True, has truthiness, is not empty; while ‘0’ if False, has falsiness, is emptly
is vs == ; is false when not in same location in memory, even if value is equal
Data Types
- Lists
- List functions(.append-adds 1 item, .extend-adds multiple items)(.insert(2,”purple”- inserts purple in seat 2))
- Defined:
thislist = ["apple", "banana", "cherry"]
- Retrieved:
listitem1 = thislist[0]
- .pop - pop() method removes the element at the specified position.
- Slices - List[start:stop:step]
- List Comprehension is used whe iterating over lists, strings, ranges and more data types
- nested listat are essential for building more complex data structures like matrices, board games, mazes
- swapping is useful when shuffling or sorting
- Dictionaries
- Get loaded by item -
items = {"name": "Eric", "age": 47, "isCool": False}
or using dict() - Defined:
thisdict = {"brand": "Ford", "model": "Mustang", "year": 1964}
- Has methods for pulling data(.keys, .values, .items)
- Get loaded by item -
- Tuples
- Ordered and unchangeable(immutable), used for protecting data, good example are GPS coordinates
- Defined:
thistuple = ("apple", "banana", "cherry")
OR tuple() - Retrieved:
tupleitem1 = thistuple[0]
- Sets - Unordered and unique; faster than lists - Defined:
thisset = {"apple", "banana", "cherry"}
OR set() - Useful for removing duplicates
- Lists
Functions
- Allows us to stary DRY(Don’t Repeat Yourself)
- ‘return’ Returns results of the funtion
Modules and Methods
- Built-in modules are available for import with standard Python installations
- Built-In modules
OOP(Object Oriented Programming)
Encapsulation - refers to encapsulating of code and methods into a class that is virtually separate from the rest of the program
Abstraction - refers to the exercise of feeding data into and getting responses from the class
Instance attributes
1
2
3
4
5class Comment():
def __init__(self, username, text, likes=0):
self.username = username
self.text = text
self.likes = likes
Instance Methods - instanciated per class
Class attributes
Class methods -
Iterator - an object that can bne iterated upon an returns data. One element at at time using next()
Iterable - Object which will return an Iterator when iter() is called on it.
Generator Functions: uses yield, can yield multiple times, when invoked returns a generator.
- ie.
sum([x for x in range(100)])
=
- ie.
Decorator - ‘@’are higher order functions wrapping other functions to enhoance their behavior
Debugging
1
2
3
4
5
6
7
8
9
10while True:
try: # this might be necessary
pass #
except: # ValueError as err and can print err
pass # there was a blank
else:
pass # input(f"Please enter some info: ")
finally:
pass # this runs no matter what,so remove if not necessary
break
Powershell
mkdir <new directory name>
- creates directoryls
- list directory, same as dirpwd
- outputs current locationecho $null >> <new file name>.py
- creates new .py file, THEN you still have to change the file to UDP-8New-Item -ItemType file <new file name>.py
- creates new .py filerm -r -fo <directory name>
- deletes ENTIRE directory; -r(Recursive for all child direcories); -f(Force prevents verifications & warnings)
Course Progress
- Course Introduction
- WINDOWS Command Line Fundamentals
- WINDOWS Python Setup
- Numbers, Operators, and Comments
- Variables and Strings
- Boolean and Conditional Logic
- Rock, Paper, Scissors
- Looping in Python
- Guessing Game
- Lists
- Lists Comprehensions
- Dictionaries
- Dictionary Exercises
- Tuples and Sets
- Functions Part I
- Functions Exercises
- Functions Part II
- Lambdas and Built-In Functions
- Debugging and Error Handling
- Modules
- OPTIONAL SECTION Making HTTP Requests with Python
- Object Oriented Programming
- Deck Of Cards Exercise
- OOP Part 2 (did not complete 7-11)
- Iterators & Generators
- Decorators (did not complete 7-14)
- Testing With Python (did not complete 3-11)
- File IO (did not complete any)
- Working With CSV and Pickling (did not complete any)
- Web Scraping with BeautifulSoup
- Web Scraping Project
- Regular Expressions
- Python + SQL
- Massive Section of Challenges
TO DO:
What did I learn / what do I need to review
[x] Print statements and variable assigning
[x] Variables and simple variable types(Numbers, String, List, Tuple, Dictionary)
[x] Complex variables(Long, Float, List, Tuple, Dictionary)
[x] Input and Ouput
[x] Loops(For, While)
[x] Conditional if statements
[x] Lists
[x] Functions and Methods(for lists)
[ ] Review “Comprehensions”, they seem useful and I don’t totally understand
[ ] Find Youtube on debugging in VScode
[ ] Go back and finish the (Did on completes)