Variable declaration
1 # -*-coding:utf-8-*- 2 3 " Brain Yang "
The code above declares a variable named: Name, and the value of the variable name is: "Brain Yang", and here's a talk about each line
# -*-coding:utf-8-*-
Declaring character encoding set: In order to display the Chinese declaration character set Utf-8,python 2.x be sure to declare that Python 3.x defaults to UTF-8 can not be declared.
" Brain Yang " # declaring variable name
The declaration variable declares a variable named: Name, the value of the variable name is: "Brain Yang", the variable type is a string, and is identified by a single quotation mark ( ‘...‘
) or double quotation mark ( "..."
). The naming conventions for variables are as follows.
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
1Name ="Alex Li"2 3Name2 =name4 Print(name,name2)5 6Name ="Jack"7 8 Print("What's the value of name2 now?")
Complete the output of the Python "Hello World"