Comments
#为单行注释
' Three single quotation marks (or "" "three double quotes) for multiple lines of comment, e.g. ' ' annotated content '
Get user input
Input ()
All data that input accepts is a string, even if you enter a number, but it is still treated as a string.
Convert data into strings with STR (transferred data); Convert string to data with int (string to be transferred).
string concatenation
"ABC" + "def" = "abcdef" "abc", "Def" = "adb def"
Operator
1. Arithmetic operators: 5//2=2 (divisible operations), 5/2=2.5;9%2=1 (division takes remainder), 2**10=1024 (exponential operation), +;-;*;/
In Python, the difference in arithmetic operations takes precedence only when the parentheses have no other parentheses.
2. Comparison operator: = = (compare size, equals);! = (comparison size, not equal); >= (compare size, greater than or equal); <= (less than equals)
3. Assignment Operator: = (Assignment), + = (for example: num+=1 equivalent to num=num+1),-= (for example: num-=1 equivalent to Num=num-1), *= (for example: num*=2 equivalent to num=num*2),/= (for example: num/=2 equivalent to num =NUM/2), similar to "//=", "%=", "**="
4. Logical operator: Not;and;or
Ture and false = False;ture and ture = ture;false and ture = False;false and false = False
Ture or false = Ture;ture or ture = Ture;false or ture = False;false or false = False
Not ture = false;not false = Ture
Logic operator Short Circuit principle:
For and, if the previous condition is false, then the expression of the two conditions of the and before and after the calculation result must be false, the second and subsequent conditions will not be computed;
For or, if the previous condition is true, then the expression of the two-conditional-or-before-or-after condition must be true, and the second and subsequent conditions will not be computed.
Note: The logical operator has no precedence.
An expression
Operator plus operand
Example: 1+2*3
You can assign a value to a variable
Example: net=1+2*3
Python learning: Commenting, getting user input, string concatenation, operators, expressions