Skip to content

Instantly share code, notes, and snippets.

@neizod
Created October 6, 2012 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neizod/3844521 to your computer and use it in GitHub Desktop.
Save neizod/3844521 to your computer and use it in GitHub Desktop.
Learn to Program: The Fundamentals

Theory

Memory

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.
  • 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 module main frame.

See Python Visualizer: http://bit.ly/Qne8fM

Practice

Function Design

TDD style

  • examples
  • type contract: (num) -> list
  • function header & parem
  • beheavior description and what to return
  • code
  • test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment