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

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 > 
主站蜘蛛池模板: 田东县| 乌审旗| 大石桥市| 宣恩县| 公安县| 邓州市| 静安区| 延川县| 黔西县| 莆田市| 太白县| 灵宝市| 思茅市| 当涂县| 寻甸| 万盛区| 尚义县| 开平市| 康保县| 孟津县| 旬阳县| 元阳县| 泾川县| 木里| 上高县| 织金县| 泸水县| 泰来县| 安乡县| 嘉黎县| 延长县| 姜堰市| 阳信县| 陇南市| 巴林左旗| 东兴市| 云梦县| 芜湖市| 五台县| 塔城市| 尼玛县|