by PDX Code Guild - March 9, 2016
Quick Notes: Python Syntax
Quick Notes are designed to be a helpful reference after a student has learned about a subject conceptually but who has not yet memorized the material. Text in blue is user dependent. Text in green changes and can be pulled from a set number of options. Python Variable name = x + y cookies = magic + sugar Function def name(parameters): return parameters * 2 def bake(magic, sugar): return magic * sugar Conditional Statements if condition 1: code to be executed if true elif condition 2: code to be executed if condition2 is true else: code to be executed if both conditions false if cookies < 20: bake more cookies elif cookies > 200: feed cookies to Cookie Monster else: keep Cookie Monster away from the cookies! For Loops for item in sequence: code to be executed for cookie in cookie_list: eat cookie