May 2016
Beginner
242 pages
4h 19m
English
The rule of variable scope in Python is defined simply: a variable created inside a function exists only inside that function. This means that a variable created inside setup() can be used only within setup(), and likewise, a variable declared inside draw() can be used only inside draw(). The exception to this rule is a variable declared outside of setup() and draw(). These variables can be used in both setup() and draw() (or inside any other function that you create). We call these variables global variables, because they can be used anywhere within the program. We call a variable that is used only within a single function a local variable. Following are a couple of code examples that further explain the concept. ...