Getting the common python variables and operators

Variables and operators are the foundation of learning of each programming language.
Python talk following common variables and operators
I. Variables
1. Definition of variables: the use of symbols to represent a changing value.
2.Java, c, c ++, c # language data types and the like are strongly, when the definition must determine what type of data storage down, such as: int a = 10; however python language data types is weak, so do not define stressed data types, such as 10 = a;
3. when defining Boolean variables must be capitalized first letter, such as: C = True; False C =
4.Python variable types are not fixed, such as: the beginning of the definition of a = 10, later on, define a = 10.05, is possible (i.e., what variables to values received, then the type of the object becomes type)
naming rules 5. variables:
composition ① variable name must be a valid symbol (uppercase and lowercase letters, numbers, underscores), python is case-sensitive language
② Do not use the keyword or reserved word as a variable name (keyword: more than 20 reserved words: the current version is not used, but later versions may be used)
③ Do not digital beginning
④ names to be meaningful: hump law: userName classRoom
underlined law: user_name class_room (python use)
two common operator.
common operator: has a special meaning, can be Data (value) symbols transport
① arithmetic operators: the mathematical symbol for transportation +, - , /, //,%
(+ has two effects: 1 2. The string concatenation data are added.)
(The modulo remainder of the process, since weak python data type, the result may be a decimal, to display an integer (floor division), or the two %% @)
, such as:
Here Insert Picture Description
a power of (* *): Here Insert Picture Description
② relationship (Comparative) operators:>, <,> =, <=, ==,! = (The only one)
(result: Boolean value (True, False))
such as:
Here Insert Picture Description
③ logical operators: and and, or or, non-Not
(the result is Boolean)
as:
Here Insert Picture Description
④ assignment operator: = , + =, - =,
=, / =, = //, ** =,% = (Python is not added from decrementing)
as:
Here Insert Picture Description
⑤ Bitwise

Published 17 original articles · won praise 2 · Views 373

Guess you like

Origin blog.csdn.net/qq_44487069/article/details/104376286