iNTERFACEWARE Products Manual > Learning Center > Learning Python > Functions and Global Variables > Local and Global Variables > Global Variables |
|
Looking for Iguana v.5 or v.6? Learn More or see the Help Center.
Variables that are defined in your main program can be used everywhere; for this reason, they are known as global variables. You can use a global variable inside a function, if you like:
Here, the function converts the value of the global variable degf to Celsius. Another option is to use global to indicate that the variable being assigned to is a global variable, not a local variable:
Here, degc is a global variable, and the print statement works as expected.
|