Constant python

table of Contents

constant

Constant is the amount does not change.

  1. Variable is the amount of change, but a constant is the same amount, python syntax is not mandatory to define constants, that is to say, python essentially defined variables constant. If you have to define the names of constants, variables must be all uppercase.
AGEOFCHEN = 19
print(AGEOFCHEN)
AG_OF_CHEN = 19
print(AGE_OF_CHEN)
#输出:
19 
19
  1. If it is constant, then we need to change, so it is only python developed a specification, but not developed syntax constants, so constants also can be modified, but not recommended.

  2. Variable is essentially constant, in order to distinguish between Variables and Constants, ChengSu convention, all caps constant, not changed.

  3. In other syntax, as there is a constant c language definition syntax, such as:

    const in age = 18

    Once you have defined age is a constant, you can not change, if change there will be wrong.

Guess you like

Origin www.cnblogs.com/chenziqing/p/11264053.html