Send
Close Add comments:
(status displays here)
Got it! This site "robinsnyder.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website. Note: This appears on each machine/browser from which this site is accessed.
Python: Variables
1. Lua: Variables
A computer variable is a named storage location.
2. Variable names
A mathematical variable is a placeholder for a value.
Variable names start with a letter and continue with a letter or digit with no spaces. An underscore character can be used but should not be used as the first character of a variable name.
A variable name identifies that variable. Such names are called identifier
3. Consistency
Whatever method you use for naming variables, be consistent within the same program or group of programs.
4. Example variable name
There are many ways to create a variable for "
total hours". Here are some ways.
totalhours
total_hours (underscore in place of space)
totalHours (camel-case)
TotalHours (camel-case)
One should not use
TOTALHOURS as all uppercase is used (by tradition) for constants (named literals).
A name such as
th (for "
total hours") is not very meaningful and should be avoided.
5. Variable declarations
The English word "declare" means to say something of importance. Example: The Declaration of Independence.
In many computer languages, computer variables must be declared and initialized before being used. (Being used means being used in an expression).
Some programming languages have implicit declarations.
6. End of page