XPYI300304 InstructorPhilipM-1 10 E - 4:45 E 10 E - 1 E 1 E - 1:45 E Lunch 1:45 E - 4:45 E chapter1.py Chapter1.py 3.8 3.9 3.12 V.R # Line Comment ''' block comments line 1 line 2 ''' variable name with data type int age = 21 Java explicitly string fname = "Philip" age = 21 implicitly age is an int from the value age = '21' im age is a string age = "21" im age is a string age = True im age bool "boolean" age = "True" im age is a string x = 7 y = 3 x + y = 10 + add x = "7" y = "3" x + y = 73 + join x = "7" x var name data type string value assigned 7 y = 3 x + y = error int(x) + y 10 x = 7 y = 3 x * y = 21 x = "7" y = 3 x * y = 777 5 * 2 + 3 # syntax yes value 13 # 25 false 5 * (2 + 3) # syntax yes value 25 # 25 true break 12:05E - 12:20E 15 minutes strings page 14 philipm@onlc.com Philip Matusiak mute "Bob" 'Bob' `injector` tick "Bob Smith" ['B','o','b','','S',] string list of chars bit byte char string int ... name = "Bob Smith" name[0] = 'B' name[4] = 'S' + join DOES NOT fname + ' ' + lname onlclabs.com python 03042024 Lunch 1:05 E - 1:50 E page 18 Booleans bool philipm@onlc.com or 800.288.8221 onlclabs.com click on python dir click on 03042024 dir copy and paste True False Boolean boolean bool() "True" bool("True") x = 7 y = 3 z = 9 x < y 7 < 3 False x < y and x < z 7 < 3 and 7 < 9 F and T F x > y and x < z 7 > 3 and 7 < 9 T and T T x < y or x < z 7 < 3 or 7 < 9 F or T T age = input("Enter your age: ") age = int(age) {"Bob","Joe","Mary","Joe","Betty"} 5 names 4 items Bob,Mary,Joe,Betty Betty,Mary,Joe,Bob Mary,Joe,Bob,Betty ("4111111125418952,12/25,524) api merchant break 4:05 EST onlclabs.com python 03042024 Day 2 > 10 EST Philip Matusiak philipm@onlc.com Day 1 Syntax Day 2 Application > Desktop / Web / Mobile / Terminal / ... functions / methods print() input() int() list() tuple() type() str() Python Core > goodies you get install python Python Standard > version additional features import keyword Python Modules / Custom Libs > pip install or custom lab and break till 11:35 E chapter 3 Modules header and footer to a new .py as functions onlclabs.com click on python dir click on 03042024 dir click on chapter3basics.py copy down run and test mymodules.py new filename > reusable myaccount.py new filename myprogram.py new filename myheader() myheader() Pythonic principle of programming in python Names myheader name of a function SEE visible _myheader hidden name __myheader attribute of an object ".py file properties" code Program > filenames.py __name__ Factory TitleCase PROVIDER UPPERCASE IO's Service TitleCase Class Properties/Attr __ OUTSIDE TitleClass Object objectName properties (var name data type) _hidden INSIDE CLASS assigned values view => UI/UX => user underscore_case camelCase lowercase Lunch 1:05 EST - 1:50 EST philipm@onlc.com 800.288.8221 page 35 "__main__" args and params 3 types of functions empty function myfunc1() NOT passing anything to the func parameterized function def fullname(fname, lname) query string parameter contactinfo(fullname, state="FL") contactinfo("Bob Smith") parameter def function [blue] property assign in the function orange p lname = input() fname = input("Enter first name") orangep fullname(fname,lname) "Bob","Smith" "Joe","Johnson" def custName(): fullname("Bob","Smith") custName.fullname() def vendName(): fullname("John","Jones") vendName.fullname() overrides overloads super() inheritance lab till 3:15 E break 3:15 E - 3:30 E functions vs methods / how to handle returns function returns itself method returns something else 6 return? DM V C M > Data Model Modules mydata.py V > View Modules C > Controller Class pip install pretty-tables Day 3 Chapter 3 10 EST recursive functions lambda functions Chapter 4 txt csv DateTime template merge / find and replace philipm@onlc.com if/for/while/switch/try keywords break continue _fname hidden variable with attr __name__ == "fname" _fname = "bob" fname var name as data type string hidden assigned value bob Lambda > anonymous ? expression / function / microservice lambda fname : fname = "Bob" taxamount = lambda subtotal : subtotal * .07 Structural print( taxamount(10) ) .07 def taxamount(subtotal): return lambda subtotal : subtotal * .07 def taxamount(subtotal): return subtotal * .07 taxamt = taxamount(10) print(taxamt) # .07 break 11:45 E - 12:00 lambdas examples page 43 lunch 1:05 E - 1:50 E example chapter 5 chapter4main.py chapter4modules.py as namespace txt lines csv rows lines Philip Bob Mary Python Core rows Philip[0] Bob[1] Mary[2] Python Standard import csv Pandas Module row/col dataframe colName[fname] row[0]=Philip Modules 3 dim Group1 row/col 'pivot' 4 dim Group2 Group1 row/col 5 dim Group3 Group2 Group1 row/col 7 dim break 3:25 E - 3:40 E csv lab