Python Programming - Variables - Discussion

Discussion Forum : Variables - General Questions (Q.No. 23)
23.
Which of the following is true about global variables?
They can only be accessed within a function.
They can be accessed and modified anywhere in the code.
They can be accessed but can't be modified anywhere in the code.
They can be accessed anywhere in the code, but can only be modified within a function.
Answer: Option
Explanation:

Global variables are defined outside of any function, and can be accessed and modified from anywhere in the code.

However, it's generally not recommended to use global variables extensively, as they can make the code harder to understand and debug.

Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.