Naming a variable

 

A variable can contain only letters, numbers and underscores. However, the first character should not be a number. Hence, a variable can be named userName, user_name, or userName2 but not 2username.


Some words cannot be used such as print, input, if, while, etc., as they already have their own functions. We will learn about these in the future.


Variable names are also case sensitive. username is not the same as userName.


Other conventions to name variables are using camel case (writing compound words in mixed casing) and using underscores (as a way to show spaces without separating the words).

No comments:

Post a Comment