Six, variable \ character encoding
Variables is used to store information to is referenced and manipulated in a computer program. They also provide a labeling data with a descriptive name, so we programs can be understood more clearly by the RE Ader and ourselves. It's helpful to think of variables as containers, that's hold information. Their sole purpose is to label and store data in memory. This data can and is used throughout your program.
declaring variables
| 123 |
#_*_coding:utf-8_*_name ="Alex Li" |
The code above declares a variable named: Name, and the value of the variable name is: "Alex Li"
Rules for variable definitions:
- Variable names can only be any combination of letters, numbers, or underscores
- The first character of a variable name cannot be a number
- The following keywords cannot be declared as variable names
[' and ', ' as ', ' assert ', ' Break ', ' class ', ' Continue ', ' Def ', ' del ', ' elif ', ' Else ', ' except ', ' exec ', ' finally ', ' for ', ' F ' Rom ', ' Global ', ' if ', ' import ', ' in ', ' was ', ' lambda ', ' not ', ' or ', ' pass ', ' print ', ' raise ', ' return ', ' try ', ' while ', ' WI Th ', ' yield ']
Assigning values to variables
| 12345678 |
name ="Alex Li" name2 = nameprint(name,name2) name = "Jack"print("What is the value of name2 now?") |
Day1_python basic _6. Variable/character encoding