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

Data types

As the name suggests, these are the classifications of the values that we pass on to the variable. A variable can be defined to store a specific type of value that can be declared based upon the data type.

There are multiple data types, but for our initial discussion there are primarily four data types that need to be understood:

  • String: This is a catch-all data type. Any value defined as a string is as simple as saying the value is plain English with characters, alphabets, special characters, and so on. I have referred to it as a catch-all data type because nearly all other data types can be converted to string format keeping the same values intact during conversion to string.

Consider the following example:

number=2

This defines that a variable named number has a value of 2.
Similarly, if we declare:

string_value="2"

This is same as saying that a value of 2 has been now defined as string and stored in a variable named string_value.

  • Integer: This specifies that any value that is a number needs to be defined with this data type. The key thing to note here is that an integer value will contain a whole number and not a decimal value:

Consider an example as follows:

integernumber=2

This defines that a variable named as integernumber has a value of the number 2.
An incorrect assignation here would be something like:

integernumber=2.4

This would give an error in some programming languages as an integer needs to be interpreted as a whole number and not a decimal value.

  • Float: This data type removes the restriction that we saw earlier with integer. It simply means we can have a decimal number and can perform mathematical calculations and storage of decimal values in a float data type.
  • Datetime: This is an extended data type found in a lot of modern scripting languages. This data type ensures that the values that are being stored or retrieved are in date format. This is typically useful if we need to create a program that uses some time or date calculations. As an example, perhaps we need to find out how many syslogs were generated from a router in the last seven days. The last seven days will be stored by this data type.
主站蜘蛛池模板: 阿鲁科尔沁旗| 卢龙县| 清涧县| 遵化市| 庆城县| 潍坊市| 新巴尔虎右旗| 神木县| 政和县| 二手房| 田阳县| 鞍山市| 武平县| 濮阳市| 喀喇| 东台市| 临清市| 浪卡子县| 固安县| 南漳县| 台江县| 哈密市| 长岭县| 南京市| 嘉祥县| 三门峡市| 仁布县| 延寿县| 五峰| 临夏市| 资兴市| 泸州市| 崇明县| 湟源县| 南漳县| 邓州市| 金华市| 家居| 洪雅县| 大悟县| 彰化市|