# Chapter2.py # line comment ''' Block Comment ''' ''' Basics of Programming Syntax 101 Requirements of the language "Python" Best Practices "Being Pythonic" Pythonic -> syntax, framework, resources cpu/memory Common Practices "Corp Principles" Operation guide on how to name conventions / organize code Basic Naming Conventions Applications Framework (Pythonic) ApplicationName -> TitleCase Filename -> TitleCase Chapter2.py no spaces, underscores recommended Factory -> Containers of Data Docker/GitHub TitleCase PROVIDER -> UPPERCASE File I/O INPUT/OUTPUT APIS Services -> TitleCase WebServices MicroServices IOTServices Classes -> TitleCase Level2 Isolate blocks of reuseabe code Class Objects -> lowercase or camelCase / blocks of output stored data at rest (memory/hard drive/buffers) property -> varname and data type first_name as string property/variable/return -> what stores a value in an object value Bob -> assign a value to a variable with an assignment operator = The value Bob is assigned to first name. The value Smith is assigned to last name. first name and last name are properties of Contact class object Contact is a member of the Contacts Class Class -> Services, PROVIDERS, Factories ''' # page 34 thru 49 ''' = assigning a value to a variable age = 21 / int age = 21 == testing a value for assigned type age = 21 testing 21 as int from the value === testing the assigned type from the var AND the value. Common NOT to use === in python ''' # Sets the variable and assigns the value in memory Python # Pythonic -> we would NEVER EVER set a variable without assigning it a value and returning it to the program aka. The of Demeter 'Priciple of Programming' # https://en.wikipedia.org/wiki/Law_of_Demeter ## 1. Did I define it? ## 2. Did I set a value? ## 3. Did I return it to be used in my program? first_name = 'Bob' # Bob is assigned to string first_name in memory. Outside wrapper is NOT a part of the value. last_name = "Smith" age = 21 # 21 is assigned to integer age in memory vipStatus = True # boolean # Get the variables values from memory to "something else" # standard output "System.stdout" -> terminal (default) # print() -> 5 core functions page 50 print(last_name) print(age) # If we want to see the data type of an object in memory we will use the type() page 50 # use the print() to see the output for type() # Python print(type(last_name)) # Pythonic -> readability as user print( type(last_name) ) # print() ''' Python Core functions -> what you get with version python, you just get these, you dont have to import these to your program Python Standard functions -> you get for each version you install from python.org BUT you have to use the "import" keyword to add them to your code. Python pip Functions -> these use HAVE to install using pip command and the import keyword Custom Modules -> custom functions Level 1 ''' # page 50 5 common core functions we use in code # print() type() int() str() input() # Convert quantity from string to int quantity = int( input("How many do you want? ") ) # quantity user string with int conversion "casting" price = 25.20 # data source total = quantity * price print(total) # return calc # EOF Chapter2.py