Python-Day2-python安装、变量与变量作用、变量和常量

Python安装

变量与变量作用

用于存信息——把数据放在内存中

描述信息——便于理解

参考:

Variables are used to store information to be referenced and manipulated in a computer program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. It is helpful to think of variables as containers that hold information. Their sole purpose is to label and store data in memory. This data can then be used throughout your program.

变量与常量

-------------------------------------------------------------

变量的修改

a=1      

a=b

print('b')    ->b=1

a=3         

print('b')    ->b=1      #b为什么还是等于1而不是等于3

           #因为a=b是把b直接指向了a的值1,而不是a这个变量本身。变量的值改变后要再执行一次a=b,这时b的值就会等于3。

-------------------------------------------------------

常量

Python中没有常量的概念,约定所有字母大写为常量。

常量   ——    AGE_OF_XX=20

原文地址:https://www.cnblogs.com/AYxing/p/8387785.html