53.3k views
3 votes
True or False:
Python global variables can be created inside functions.

1 Answer

6 votes

Final answer:

True, Global variables can indeed be created inside functions in Python by using the global keyword before the variable declaration, making the variable accessible outside the function.

Step-by-step explanation:

The question True or False: Python global variables can be created inside functions is about a concept in Python programming, which falls under the Computer Science domain, specifically related to variable scope and management. The answer to this question is True. In Python, global variables can be created inside a function using the global keyword before the variable name. For example:

def myFunction():
global myVar
myVar = "I am a global variable"

Here, myVar becomes a global variable that can be accessed outside the function as well. However, it's generally recommended to avoid using global variables extensively as they can make the code harder to read and maintain.

User Aalbahem
by
8.5k points