
Type binding of Python
Python is using dynamic type binding rather than static binding. In Python, users need not to declare the variable type but just the variable name. Python will automatically set the variable type during run-time when Python interpreter translate the codes line by line.

More
However, if the users can change the variable’s data type via str(), int() to do operation on it. As you can see at the following codes, we assign 12 to a variable, which is tacocat. Then, we check the data type. Python assign integer to this variable, but we can change it to string with str().

Type Binding
Python is using dynamic type binding rather than static binding. In Python, users need not to declare the variable type but just the variable name. Python will automatically set the variable type during run-time when Python interpreter translate the codes line by line.

However, if the users can change the variable’s data type via str(), int() to do operation on it. As you can see at the following codes, we assign 12 to a variable, which is tacocat. Then, we check the data type. Python assign integer to this variable, but we can change it to string with str().

Static/Dynamic Scoping
Python is statically scoped. This simply means that every mention of a variable name in a program can be resolved ahead of time in order to determine the object to which it refers, by inspection only of the program’s text.


The value returned by fun2() is not dependent on who is calling it (Like fun1() calls it and has a x with value 7). fun2() always returns the value of global variable x. The compiler first searches in the current block, then in the surrounding blocks successively and finally in the global variables. The final value of X is 3.
1) Search for X begins in fun2(), but no declaration for X is found.
2) Search static parent of fun2(), declaration of X is found. X in fun1() is ignored, because it is not in the static ancestry of fun2().
​As Python uses static scoping, we will use the same code as mentioned before as our dynamic scoping example. Using dynamic scoping rules, the output of the program would be 7.
This is because in dynamic scoping the compiler first searches the current block and then successively all the calling functions. The final value of X is 7.
1) Search for X begins in fun2, but no declaration for X is found.
2) Search dynamic parent/calling function of fun2, declaration of X is found in fun1.