Local Variables & Global Variables

 


 

First, the definition

Local variables are defined inside a function of variables may only be used in a function. Function can not be used outside. Similarly, global variables can be used inside and outside the function.

= Money 0 

DEF earn (): 
    Global Money 
    Money + = 280 

DEF Exhaust (): 
    Global Money 
    Money - = 720. 
Print ( ' initial Money ' , Money) 

earn () 
Print ( ' after money Money ' , Money) 

Exhaust () 
Print ( ' after money Money ' , Money)

Print Results:

The initial Money 0 
Money money after 280 
Money after money - 440.

 

Guess you like

Origin www.cnblogs.com/zzsay/p/10986283.html