官术网_书友最值得收藏!

Variables

So, what is a variable? Consider that your house needs a name. You place a nameplate at the front gate of your house. People will now recognize your house through that nameplate. That nameplate can be considered as variable. Like a nameplate points to the house, a variable points to the value that is stored in memory. When you create a variable, the interpreter will reserve some space in the memory to store values. Depending on the data type of the variable, the interpreter allocates memory and makes a decision to store a particular data type in the reserved memory. Various data types, such as integers, decimals, or characters, can be stored by assigning different data types to the variables. Python variables are usually dynamically typed, that is, the type of the variable is interpreted during runtime and you need not specifically provide a type to the variable name, unlike what other programming languages require. There are certain rules or naming conventions for naming variables. The following are the rules:

  • Reserved key words such as if, else, and so on cannot be used for naming variables
  • Variable names can begin with _, $, or a letter
  • Variable names can be in lower case and uppercase
  • Variable names cannot start with a number
  • White space characters are not allowed in the naming of a variable

You can assign values to the variable using = or assignment operator.

Syntax:

<variable name>= < expression > 
主站蜘蛛池模板: 宣化县| 白沙| 茶陵县| 泾阳县| 武陟县| 开封市| 南江县| 赫章县| 体育| 卓尼县| 天津市| 望奎县| 修武县| 大理市| 景德镇市| 波密县| 分宜县| 都匀市| 洞头县| 阜康市| 库尔勒市| 慈溪市| 峨山| 咸阳市| 营山县| 迁安市| 宣恩县| 芦溪县| 阿克苏市| 象山县| 廊坊市| 长沙市| 全椒县| 黄山市| 龙岩市| 屯门区| 长治市| 凤阳县| 滨海县| 钦州市| 宁安市|