Featured Post

Why this blog? What's it about? What's the format?

FORMAT For Fall 2021, the focus is mainly on Python, C++, and Digital Hardware There are videos here from other sources / creators There are...

Right click image below, then "open link in new tab"

Right click image below, then "open link in new tab"
Right click image above, then "open link in new tab"

Search This Blog

Saturday, September 11, 2021

Python Programming Language Notes

(Only scant, random, scattered main topics here. Not detailed or comprehensive)

ABOUT Python Code:

  • Versatile - Works on Windows, Mac, Linux, Supports Object-Oriented and Structured programming 
  • High level - Uses natural language to present abstract programming functions
  • Dynamically typed - Variable types change, based on the data they hold rather than being declared statically on creation
  • Multiple libraries - Open source, easily accessible, many modules containing predefined definitions for easy functionality
  • Incompatibility - 3.x incompatible with 2.x code
  • Importing modules - import x, import x as y, from x import functional1, from x import *, dir(x)
  • Scope - indentation
  • Global scope - accessible by whole program, will persist until program runs
  • Meaningful indentation - indentation deleanates change in scope (more indentated to left means narrower), each segment of indentation is equal to 4 spaces (don't use tabs) 
NAMING Conventions:
  • Uppercase vs. lowercase - Class names are uppercase, all others are lowercase
  • Leading underscores - Underscore before name is privatization. Function names that begin with 1 will not be imported when using the "from x import*" statement 
  • Trailing underscores - Single underscore after name is used to avoid naming conflicts. A double underscore after a name is used in conjuction with a double underscore before a name to indicate name with a special function 
  • Reserved keywords - Some words have special function, and can not be used to name variables, functions or classes (examples: and, as, assert, break, class, continue, def, del, elif, else, except, exec, False, finally, for, from, global, if, import, in, is, lambda, None, nonlocal, not, or, pass, print, raise, return, True, try, while, with, yield)
  • Comments - explain in plain language
  • Triple quotation marks - docstring to explain purpose
  • Pound sign - Comments using # sign when describing how, why, what of code
WRITING Code Basics:
  • Making variables - Declaration and assignment, assigning variables
  • Types - Integer, Floating point (float), Complex, String, List, Tuple, Boolean (bool), Dictionary (Dict), Changing types 
  • Console - Outputting text, taking user input
  • Error handling - try, except, else, finally, raise
  • Saving and loading files - open(filename, mode), file.read(size), file.readline(), file.write(), file.close()
Coding STRUCTURES:
  • List operations - List, tuple, & dict
  • Math operators - (int, float & complex)
  • Strings - test values without any meaning (mathematical or logical)
  • Statements - commands that initiate operation. Boolean, For, While, 
  • Functions - used to break down operations into smaller, reusable chunks
  • Dictionaries - special list types that contain key value pairs. 2 dimensional arrays with unique identifier keys attached to values
USING Structures:
  • String formatting - Using, Returns, Other formatting options
  • String methods - Slicing, reversing, splitting, joining, enumerating
  • Escape sequences - newline, printing special characters literally
  • Bool characters - used to perform operations related to true and false statements
  • Writing Boolean statements - Alternate if-else, Nesting if
  • Recursion & iteration - Recursion, Iteration, Break, Continue, 
  • Classes - Creating, filling
Coding CONCEPTS
  • Inheritance - Process by which objects gain properties of other objects. Classes, for example. 1st - Parent class. 2nd - Child class. Children can overwrite the inherited properties of their parent, changing functionality. Overriding. Inheritance from multiple parents. 

No comments:

Post a Comment