Variable declaration variable
1 # !/usr/bin/env python 2 3 4 " Bourbon "
The code above declares a variable named: Name, and the value of the variable is: "Bourbon"
The role of a variable: A variable has an identity meaning, which refers to what is stored in an address in memory
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 (but you can start with "_") and a space cannot appear in the variable name
· Keyword cannot be declared as a variable name:
[' 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 ']
PS: When encountering complex variable names by "_" to separate multiple words or capitalize the first letter of a word (camel body)
Assignment of variables:
1 # !/usr/bin/env python 2 3 4 " Bourbon " 5 " Sheldon "
1>>>name1 ="BOurbon"2>>>name2 =name13>>>Print(name1,name2)4 5 #Output6BOurbon Bourbon7 8 9>>>name1 =' SHeldon'Ten>>>Print(name1,name2) One A #Output -Sheldon Bourbon
Python learns the "third" Python variable