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

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 > 
主站蜘蛛池模板: 云和县| 手机| 青铜峡市| 东莞市| 恩施市| 金阳县| 河津市| 南康市| 丹凤县| 达尔| 航空| 忻州市| 台南市| 德令哈市| 平泉县| 衡水市| 泗水县| 安阳县| 聊城市| 青岛市| 通榆县| 巍山| 榆中县| 绵阳市| 长宁区| 西青区| 沙湾县| 会同县| 杭州市| 彰化县| 惠东县| 永和县| 玉溪市| 佛学| 内黄县| 三原县| 隆尧县| 获嘉县| 通江县| 七台河市| 东乌|