There are 2 places of memory in Python program.
- Heap: value of variables, functions recipe bind w/ memory address. e.g.
- memory addr:
x1
-> int: 42 - memory addr:
x2
-> str: 'hello' - memory addr:
x7
-> function: take one parametor as x and return x^2.
- memory addr:
- Stack: track name of variables and functions, stage of program. e.g.
- variable name: ans ->
x1
(so ans has value 42 of type int) - function name: sqr ->
x7
- execution stage: now in function
sqr
frame, over modulemain
frame.
- variable name: ans ->
See Python Visualizer: http://bit.ly/Qne8fM
TDD style
- examples
- type contract:
(num) -> list
- function header & parem
- beheavior description and what to return
- code
- test