python学习(二):变量详解

  1. 变量的定义
  2. 变量的命名规则
  3. 常量

1.变量的定义
变量是为了存储程序运算过程中的中间结果,为了方便日后调用。

官方定义: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.

2.变量的命名规则
(1)要具有描述性。
(2)变量名只能_、数字、字母组成,不可以是空格或特殊字符。(#*?。,)
(3)不能以中文为变量名。
(4)不能以数字开头。
(5)保留字符是不能被使用。
(6)变量名区分大小写。
python中的关键字有:

and                 elif                import              return
as                  else                in                  try
assert              except              is                  while
break               finally             lambda              with
class               for                 not                 yield
continue            from                or
def                 global              pass
del                 if                  raise

3.常量
常量:不变的量 pie = 3.141592653……
在python里所有的变量都是可变的,所以用全部大写的变量名来代表此变量为常量。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值