Section 3. Chapter 2
single
Local vs. Global Variables
Swipe to show menu
Task
Swipe to start coding
Create a function that demonstrates the difference between local and global variables by modifying a global variable inside a function.
-
Use the
globalkeyword to modify the global variablexinside the function; -
Assign the value
20toxwithin the function; -
Create a local variable
yinside the function and assign it the value5.
Solution
Everything was clear?
Thanks for your feedback!
Section 3. Chapter 2
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat