Python for Finance Chapter1~3

Python_for_Finance.pdf

Chapter2: 把Python当成普通计算器使用

变量定义不需要事先声明

##使用dir()查看已有的变量和函数

关于局部变量和全局变量的LEGB规则

Python中的LEGB规则

Items meanings
L Local refers to names assigned in any way within a function (def) and not declared global in that function.
E Enclosing refers to enclosing function locals, such as names, in the local scope of any and all enclosing function (def).
G Global refers to names such as assigned at the top level of a module or declared as global variable within a function defined by def.
B Build-in refers to names pre-assigned in the build-in-modules, such as open, range, and SyntaxError.

Items meanings
Local 可能是在一个函数或者类方法内部。
Enclosed 可能是嵌套函数内，比如说 一个函数包裹在另一个函数内部。
Global 代表的是执行脚本自身的最高层次。
Built-in 是Python为自身保留的特殊名称。

pow()函数和**的区别

$$pow(x, y, z) = mod(x^y, z)$$

fin101.py