Python-variables and common operators

Python variable:
What is a variable:
the amount that can change while the program is running.
The variable is a memory space with a name to store the value.
1. Stack memory (stack): FILO
last in first out
2. Heap memory

How to define variables in python:
variable name = variable value
strong data type language: java c c++ C#
data type variable name = variable value;
int num =100;
weak data type language: python PHP ruby ​​JavaScript
var variable name = variable value;
variable The naming conventions:
1. The variable name must be composed of valid symbols such as numbers, uppercase and lowercase letters, and underscores (_).
2. The variable name cannot start with a number.
3. The keyword or reserved word cannot be used as the variable name
. Meaning (try to follow)
5. Try to follow the underscore (user_name) or small camel case (capitalize the first letter of the word)

Common operation points:
1. Arithmetic operator: +-* /% // ** (Power: the second number is how many times)
2. Relational operator:> <>= <= == !=
3. Logical operator: and or not
4. Assignment operator: = += -= *= /= = = * *=
#Assignment, assign the value on the right side of the equal sign to the variable on the left
#a+=10 <==>a=a+10
5, ternary operator
6, bit operator: the lowest operator of the computer & | ^
7, shift operator: >> (right shift) << (left shift)
8 , Owning operator: in
Note: Addition and subtraction operator, note that Python does not provide this operator
a+=1 a-=1 (only this form is different from C language)

Guess you like

Origin blog.csdn.net/weixin_45802686/article/details/108719797