Graphics
Graphics package is not standard Python
Applications Programming Interface (API)
Review of Functions
Reasons to Use:
1.
Organization & Design—Divide and Conquer
2. Replace Duplicated Actions—karaoke examples
Parameters
1. Formal and actual
2. Must pass everything you need (unless using global variable which you shouldn't)
Global variables
1, Very bad programming style
2. Don't use in this course
3. Typically, used only for very large data structures you don't want to copy
Returns
1. Last line of function & only one per function
2. In Python, can return single or multiple values as tuples
3. Used to change values
Aside 1: Tuples
Like list but immutable and uses parentheses rather than brackets
Aside 2: Update operators
1. +=, -=, *=, /=, and %=
2.
Examples—x += 1 or y *= y + 2
3. Fully evaluate right side before applying to update
E.g., x *= 2 + 3 IS x = x * (2 + 3), NOT x = x * 2 + 3
Homework: Energy Density Calculator with GUI