In the past post, I was learning what is the variables in the programming languages. Now, I will learn the variable name and keywords. And also I tried the IDLE of Python. If you do not know what is the IDLE, visit this Python’s Integrated Development and Learning Environment. Before I continue how to learn the variable names and keywords. I have to recall what is variable.
A variable in programming languages is a name that refers to a value. I will learn here how to name variables.
Visit the variables in programming languages post to recall what I learn there. If you are not yet familiarized with variables.
Programmers can choose names whatever they want to a variable. However, it is necessary that the name is meaningful. You cannot name a variable that stored ages data to fruits. Has to be the same name as “ages”. Is not that difficult to names variables. First, you have to think about what is the data to be stored. Then you can choose the proper name.
Characteristics of a variable names
- Variables names can be arbitrary long.
- Can contain numbers and letters.
- Have to begin with letters no numbers this is so important to remember.
- It is legal to use uppercase letters.
- Is suggested that your variable begins with lowercase.
The first error is an syntax error as you see. By cause of the first number in the variable name. Is not acceptable for the interpreter to execute the program.
The second error is an illegal character #.
The third error is illegal by reason of using a keyword. I will see this and learn about it.
Underscore in the variables names is acceptable. You can write names like this peter_ages and math_grades_this_semester. But think that it is better to simplify the variable names to clearly understand.
The interpreter uses keywords to recognize the structure of the program, and they cannot be used as variables names. These words are already reserve for the program. So we cannot use it to name the variable.
Python has 30 keywords.
This will be my reference to avoid seeing in debugging. Or you can do this in the IDLE.
Variable names have to be simple and understandable. This is all for today. Tomorrow I will learn the advance of programming. The statements, operators, and operands that show us to write our code.