Python Programming - Variables - Discussion

Discussion Forum : Variables - General Questions (Q.No. 2)
2.
Which of the following is not a valid variable name?
my_variable
123_variable
_my_variable
MY_VARIABLE
Answer: Option
Explanation:

In Python, variable names must begin with a letter or an underscore, and can be followed by any combination of letters, underscores, and numbers.

Here are some examples of valid variable names in Python:

my_var
MyVar
_myVar
MyVar123
age
x25
india_bix_com

Here are some examples of invalid variable names in Python:

2myvar
my-var
my var
food+nonfood

Variable names in Python must start with a letter or an underscore. They can contain letters, numbers, and underscores. They cannot start with a number or contain any spaces.

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

Post your comments here:

Your comments will be displayed after verification.