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)
    • 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

  • 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
      5
      class 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)]) =
  • Decorator - ‘@’are higher order functions wrapping other functions to enhoance their behavior

  • Debugging

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    while 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 directory
  • ls - list directory, same as dir
  • pwd - outputs current location
  • echo $null >> <new file name>.py - creates new .py file, THEN you still have to change the file to UDP-8
  • New-Item -ItemType file <new file name>.py - creates new .py file
  • rm -r -fo <directory name> - deletes ENTIRE directory; -r(Recursive for all child direcories); -f(Force prevents verifications & warnings)

Course Progress

  1. Course Introduction
  2. WINDOWS Command Line Fundamentals
  3. WINDOWS Python Setup
  4. Numbers, Operators, and Comments
  5. Variables and Strings
  6. Boolean and Conditional Logic
  7. Rock, Paper, Scissors
  8. Looping in Python
  9. Guessing Game
  10. Lists
  11. Lists Comprehensions
  12. Dictionaries
  13. Dictionary Exercises
  14. Tuples and Sets
  15. Functions Part I
  16. Functions Exercises
  17. Functions Part II
  18. Lambdas and Built-In Functions
  19. Debugging and Error Handling
  20. Modules
  21. OPTIONAL SECTION Making HTTP Requests with Python
  22. Object Oriented Programming
  23. Deck Of Cards Exercise
  24. OOP Part 2 (did not complete 7-11)
  25. Iterators & Generators
  26. Decorators (did not complete 7-14)
  27. Testing With Python (did not complete 3-11)
  28. File IO (did not complete any)
  29. Working With CSV and Pickling (did not complete any)
  30. Web Scraping with BeautifulSoup
  31. Web Scraping Project
  32. Regular Expressions
  33. Python + SQL
  34. 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)