''' myInformation.py x = 7 # x variable name = assignment 7 int(data type) value data types > byte, char, string, int, .... types > data, reference, class, interface, ... y = "3" # y variable name data type string value 3 a = 7 b = 3 c = a + b # addition operator fname = "Bob" lname = "Smith" fullname = fname + " " + lname # string join Built In Functions Python Core (install python) print(), input(), int(), type(), str() if (condition): sub operations elif (retest condition): sub operations else: final sub operations if everything returns False conditional tests > relational and/or logical operators x > 7 and y < 4 relational op'>' logical op'and; relational op'<' remember to define the var name on the second opration x < 7 and > 4 INCORRECT x < 7 and x > 4 CORRECT List fnames = ['Bob','Sue', 27] brackets length(3) index[0-2] 'Bob' string element[0] 'Sue' string element[1] 27 int element[2] applying the 's' as a best practice for a multiple object , seperates the elements in a collection(list,set,tuple,dict) for x in ys: # for loop x local variable in scope(sub operations) and ys is "where are we getting or data from ?" for fname in fnames: print(fname) Chapter 5 Discussion Syntax Error > physically typed the code wrong RED PROBLEMS VS Code > Terminal Problems ERRORS Runtime Errors > Errors that happen at runtime when the syntax is correct mismatched data types, calling an object that does not exist.have access to, exception errors at runtime, "start the program" Exception Errors > Error handling > errors that occur sometime after the start/init/runtime of program Python > try except finally statement ''' # Empty Function ## Step 1. Define the function with def keyword in Python ## Empty function takes on NO parameters / empty (tuple) ## () has to be attached at the end of the function name / no whitespaces ## : (colon) to define the scope/sub operations of the function ## the definition of the function does not have to be in the same file as the call of the function, it just needs to have access to it (aka import keyword) ## You can not call a function that A. Is not defined or B. You dont have access to def myCalculator(): # def keyword myCalculator is the name of the function and the function has no parameters() (data passed to the function from another object) x = 7 y = 3 z = x + y print(f"Result: {z}") # Result: 10 using template variable and the f keyword print("Result:" + " " + str(z)) # casting the int as string join print("Result:",z) # parameterization in the tuple (ignores data type) # Step 2. Call the function myCalculator() # Defining a function with parameters # args need to be passed to params in positional order # vars can be assigned individually to args def myFunctionName(param1, param2 = "No Team Assigned", param3 = "No Team Assigned"): # Only define parameters that you need in the scope of the function # assign each param to a local variables var1 = param1 # 1st var3 = param3 # 2nd var2 = param2 # 3rd # Control (if statement) to test the number of winners, if param = "No Team Assigned" if var1 == "No Team Assigned": print() # create the operations we need to return print("Winning Order: ", var2, var3, var1) # Call the function and pass 3 args argMethod1 = "Team 1" argMethod2 = input("Enter Your Team Name: ") # A call with 3 teams being passed myFunctionName(argMethod1, argMethod2, "Team 3") # A call with 2 team names being passed myFunctionName(argMethod1,argMethod2)