XPYI301204 InstructorPhilipM-1 10 E - 1 E 1 E - 1:45 E Lunch 1:45 - 4:45 E VS Code / Web Juypter Notebook / CoLab Visual Studio / Intellij variable name firstName data type string property = variable name data type assign value to properties firstName = "Bob" age = 40 age as int assigned value of 40 = == === # docstring h1 ## h2 ### h3 FIRSTNAME break 11:35 E - 11:50 E page 10 math... philipm@onlc.com Order of Presidence wrapper arithmetic operators Excel Python Core or Math Modules 1 + 2 * 3 = 7 (1 + 2) * 3 = 9 int or decimal do not wrap the value in ` ' " " ' ` + add + join / concat "21" + "47" = 2147 21 + 47 = 68 "21" + 47 !error int("21") + 47 = 68 "21" = 47.toString() = 2147 PYTHON gets the data type from value assignment IMPLICITLY 21 int "21" string vipStatus = True boolean vipStatus = "True" string string vipStatus; vipStatus = "False" variable name vipstatus data type string value False types: data,ref,class,provider,interface,custom,error debug code IDE syntax errors debugging "Problems" runtime errors code syntax correct > oninit() contacts.csv exception errors onSubmit() 'char' and "string" OOP "Philip" = ['P','h','i','l','i','p'] len(6) range 0-5 firstName[0] print 'P' firstName[5] print 'p' byte > char > string[a-z][A-Z][0-9] 'b' < '9' fName fname firstName first_name fname lname add1 add2 city st zip statically typed in the code flat file stdin terminal input() db csv form input cookie session variable localStorage api web service json odbc jdbc lunch 1:05 E - 1:50 E philipm@onlc.com [bracket {braces (round brackets . dot notation static value input() value looping while control OUTSIDE of the loop for control INSIDE of the loop 1. test (condition) 2. index (control) 3. break (continue) for x in ys: # ys data from todos x is varible INSIDE scope VIRT > Tools>Preferences checkbox copy/paste h1-h6 x = "Bob" 1 dim assigned value y = "fname" 2 dim col (x row) (x,y) (row,col) z pivot 3 dim z (x,y) g1 z (x,y) 4 dim g2 g1 (x,y) 5 dim g3 g2 g1 (x,y) 6 dim g4 g3 g2 g1 (x,y) 7 dim fName = "Bob" > memory lab till 3:20 break 3:20 - 3:35 E What contact do you want to update? 3 Traceback (most recent call last): File "c:\python\my_python\chapter2.py", line 57, in firstNames[contactIdToUpdate] = "Robert" TypeError: list indices must be integers or slices, not str int( input(str) ) contacts { contact { "fname": FIRSTNAME } # } # Day 2 10 EST - 4:45 EST dict contact 12 contacts > List [ { k:v }, { k:v }, .... ] input(ccNum) input(ccExp) input(ccCVC) call("4111","12/25",452) inputted def(ccNum, ccExp, ccCVC) params api(p1,p2,p3) api merchant arg> param input> output import> export get>post inj>class contacts () contacts.append() inValid contact[0] = "new cc num" https://onlclabs.com/python/12042023/ break 11:25 E - 11:40 E labs for tuples page 30 reference str + tuple.item str, tuple.item List [12,52,24,98,52] len(5) range(0-4) R/W append dups 12,52,24,98,52 Tuple (12,52,24,98,52) len(5) range(0-4) R dups 12,52,24,98,52 Set {12,52,24,98,52} len(4) !dups !range(!sort,!index) 52,98,12,24 98,24,12,52 24,12,98,52 products = {} App factory PROVIDERS services Memory <<< classes objects > API COVERT userInputs() prop = var and data type assign prop values .format() template view create a new chapter3.py file basic function page 38 main function page 35 back to the normal page order for x in ys { # sets ys { #set x ( string, int ) #row row, col } , { [int, int, int] row, col }, { (dt, bool, string) row, col }, { { k:v } row col } } for ys in dim4: for x in ys.dim4: for set in sets for row in x.ys#.dim4: print(row,col) for tuple in set for list in set for tuple in set for dict in set 1. define it kite ? access 2. give it value lightning 147 3. return it string ? last one Class.Obj.method().method().value def orderTotal(cart_total): taxRate = 7 orderSubTotal = cart_total orderTax = orderSubTotal * ( taxRate / 100 ) orderTotal = orderSubTotal + orderTax print(orderTotal) # last step give it value 4 pages home orders contacts products break 3:30 E - 3:45 E return the userInputs() 3 types of functions def myfunc() empty parameter def myfunc(param1, ...) parameterized function def myfunc(param1="value", param2, ...) query string parameter public static void main(string[] args) { } Program.cs Program() Angular app.Module main() if __name__ == "__main__": main() main visible _main hidden / anonymous lambdas __main Property / meta Property = object Property type property = var with data type Day 3 10 EST python core < print() input() int() python standard < installed csv datetime import customs < your coding or pip import myapp.py < main runtime myfunctions.py < library of functions shopping cart contacts.py addNewAddress() updateAddress() accounts.py changePassword() shop.py cart.py addToCart() creditcardproc.py orders.py import ModuleName (filename without the .py) from ModuleName import Class or Object Name import ModuleName as Namespace DRY Law of Demeter Pythonic Lambda name = lambda params: exp Ask the Question? define, value, return def fullname(fName, Name): # Object first_name = fName # Prop last_name = lName # Prop fullname = fName, lName return fullname # View def fullname(fName, Name): fullname = fName + ' ' + lName # Property return fullname # View full_name = lambda firstName, lastName: f"{firstName} {lastName}" # view lab 11:45 E break 11:45 E - 12:00 E page 43 lambda operation arthimetic op * / + - ... comparison op == < > ... logical op AND OR NOT & && | || ! assignment += -= *= = bit op membership op in not not ["FL","IA"] identity op is is not string op list, tuple, dict, operations control flow op if for DateTime Modules mm/dd/yyyy HH:MM:S.MMMM UTC+0 todaysDate = "12/06/2023" property __name__ todaysDate property type data / string property value 12/06/2023 todaysDate1 = 12/06/2023 12:31:24.124758 UTC+0 property __name__ todaysDate1 property type Class / DateTime property value 12/06/2023 12:31:24.124758 UTC+0 Today's Date is + ? string Net30DueDate = todaysDate1 + 30 1. New Type Class 2. DateTime Module > Standard Module import keyword BUT from / import keyword datetime Module time Class > specific time independent date !international date Class > specific date independent time !UTC 00:00.0.0000 datetime Class > specific date time UTC datetime stamp import datetime # import Module datetime.datetime.function() #Module.Class.function() from ModuleName import Class from datetime import datetime from datetime import date datetime.function() # Class.function() {} purple square orange tree lunch 1:05 E - 1:50 E lab datetime Module page 67 break 3:25 E - 3:40 E write to our csv file add the Exception if the file does not exist try except finally Exit Code 0 passed Exception Handler try finally Exit Code 1 failed <<<<