COMPSCI 61A Lecture Notes - Lecture 2: 2
zogo39484755 and 6 others unlocked
22
COMPSCI 61A Full Course Notes
Verified Note
22 documents
Document Summary
Names, assignment, and user-de ned functions from math import pi // import things you need from python"s built-in values area, circ = pi * radius ** (cid:617), (cid:617) * pi * radius // assign multiple values built-in functions (ex max(cid:383)(cid:384) ) can be reassigned to variables. >>> f(cid:383)(cid:617), (cid:619)(cid:384) (cid:619) don"t assign built-in function names to other values if you do, then do builtins. max to x it. Environment diagrams environment diagrams visualize the (python) interpreter"s process. Code (left): statements and expressions arrows indicate evaluation order (green: just executed; red: next to execute) Frames (right): each name is bound to a value within a frame, a name can"t be repeated. Assignment is a simple means of abstraction that binds names to values. Function de nition is a more powerful means of abstraction: binds names to expressions def (cid:383)(cid:384): return Function signature indicates how many arguments a function takes.