Hello there, we are back with another article and in this article, we are going to learn about data types. We will learn this using few examples. Just make sure you have already installed python on your computer. Click here to learn more – https://goo.gl/VfoUhA
Let’s try to learn about datatypes. In simple terms, datatypes are something like the states of matter. We have solid, liquid and gases, similarly, in programming, we have something that holds letters aka alphabets, numbers aka integer values, etc. So datatypes are basically the type of data that we are going to feed in. It can be a number, it can be an alphabet or stings of alphabets.
Let’s try to learn using some examples:
Python – The word python is written in letters
1,2,4 – These numbers are nothing else than integers.
Now let’s take a deep look into datatypes in Python. Here we are basically learning what type of data can be fed into which datatype.
As we all know, integers are normal integer numbers without decimal numbers. These numbers are integers they can be positive as well as negative as long as fractions are not fed.
For Example: 1 , 2 , …… 99 as well as -99 , -98 , .. 0.
A float is also a number datatype but unlike integers, floats can contain decimal and fractions. The main part to learn here is that if you fed a value ‘1’ to float datatype it will always return ‘1.0’. Technically 1 and 1.0 are same but float tends to work with decimals.
For Example: 1.0, 25.55, etc.
A character is something that holds alphabetically values which includes special characters. The main part to learn here is that if you want to feed a value ‘a’ into a character datatype, you must always enclose it in “” or ”.
For Example: ‘a’, ‘b’, ‘c’, ‘@’, ‘$’, ‘%’.
This is the most important data type in python. Strings are basically set of character and numbers. It also accepts special characters. Numbers and fractions are also part of strings. As always, fed strings using ” or “”
For Example: ‘Teja123’, “0.5”, “123”.