CS61A - Lin Growing

Lecture 3 · Multiple Environments

On this page

enviroment

  • A call expression and the function body are evaluated in different environments.
  • If the function is defined in the global frame, its indented body executes in a local frame.

operators

  • Operators are functions that perform operations.
    • 2 + 3 * 4 + 5 = add(add(2, mul(3, 4)), 5)
    • divide
      • 2013 / 10 = 201.3 (truediv)
      • 2013 // 10 = 201 (floordiv)
      • 2013 % 10 = 3 (mod)
  • Returning multiple values:A function returning multiple values

Documentation Tests

  • $ python3 -m doctest -v ex.py
    • python3: start Python
    • -m: run a module:
    • doctest: the Python documentation-testing module
    • ex.py: the file

English translation · Read Chinese original