Python "Variables"

Source: Internet
Author: User

This article describes
1. Definition of variables and usage specifications

I. What is a variable
变量方便储存数据,以供程序随时调用。计算机的主要功能:运算、通信
Two. Basic functions of variables
变量:    作用:存贮程序的中间结果在内存里,以备后边的程序调用定义规范:    变量名只能是 字母、数字活下划线的任意组合    变量名的第一个字符不能是数字    python中的关键字不能作为变量名命名习惯:    驼峰体  FilePath    下划线体  file_path(官方推荐)不建议的命名习惯:    变量名为中文、拼音    变量名过长    变量名词不达意
Three. Application of variables
a=1b=a # 给变量b赋值变量a的内存地址,该内存地址指向1a=2 # 修改a的内存地址指向2,但是变量b的内存地址不变print(a) #2print(b) #1
Four. Constants
特点:常量即指不变的量,如pai 3.141592653,或在程序运行过程中不会改变的量在python中没有一个专门的语法代表常量,规范使用变量名全部大写代表常量

Python "Variables"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.