Why we are use data type | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 25

Why we are use data type

23rd Mar 2020, 5:36 AM
Chaitanya Dnyaneshwar Kuwar
306 Answers
+ 195
Hi, Data types are the type of data or the category of data which we will be using for the program. It can be anything starting from the integer data type to boolean data type for true and false, they tell the type of the data which is gonna be inserted or used. Some very basic data types and their brief description is given below:- 1)int - integer data type(0,1,2,3,4…10…1000….n) 2)char -character data type(a,b,c,d,e,f,g,h……,z) 3)float-floating data type(In this data type we can store any decimal point number with up to 17 significant digits, e.g:-5.645, 86.8442, 9.1, 1.0, 1.1234552454,…etc ) 4)double-Double Floating Point data type is used for storing double precision floating point values or decimal values.(e.g:-1.142, 2.1, etc) 5)bool - Bool data type is used to store logical data types, <Strong>True or False</strong>. Data types are important in programming languages, so that the memory which has to be given to store a particular data that can be stored. Data types tells MMU that how much memory requirement it has before the program compiles
24th Mar 2020, 9:43 AM
AjayGohil
+ 86
Data types are used to specify what type of value will be stored in variable
23rd Mar 2020, 5:37 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 47
Data type are used for different type of data Integer for addition 4+5= 9 String for concatenation "4"+"5"= 45 "Num"+"ber"= number
25th Mar 2021, 5:45 PM
AJAY KUMAR
AJAY KUMAR - avatar
+ 24
I thought I would add to this discussion by putting in a common programming error for new coders. Data types really matter when you are designing input forms. If the end-user is being asked, for example, to input a phone number BUT the form is coded to see the input as a STRING, or as numerical digits, or as text--it all means differences in how the data is input, stored, able to be processed and it may even produce an error message for the person trying to input if the data type on the input field doesn't match what kind of data they are trying to input.
11th Apr 2021, 7:39 PM
EO4Wellness
EO4Wellness - avatar
+ 18
computer need to know data type so that it can alocal space in memary to store. other reasion data will diside their mathods on their type.
15th Mar 2021, 5:15 AM
渔夫老师
+ 11
A very simple explanation would be that the very nature of data is divergent , most times when creating a program and we want to store data in variables , we need to decide whether we want precision in our calculations( use of float , decimal point data types) , or simple calculations with the use of whole numbers ( integer data types) , sometimes we may not even want to use numbers but characters instead or use numbers as characters as well( although chars can be added together using basic arithmatic , it does not mean that the operation will be the same as that of calculating with integers, the result will just join the 2 or more characters together) If you ever get the chance to study other languages namely C , C++, Java , you will begin to understand why data types are relevant . It is unfortunate ( or fortunate) that Python does not really follow the convention of declaring data types, as it will automatically know which data type it is dealing with depending on how you define the data in your program.
2nd Apr 2021, 4:27 AM
Joakim Bongani Munyanyi
Joakim Bongani Munyanyi - avatar
+ 8
you need it to know the conversation,
22nd Mar 2021, 8:19 PM
Techno.uae
Techno.uae - avatar
+ 8
Data types is a container which holds the data, like of you want to store integer value then use int, if you want to put value like any name then use string, boolean, char, etc..
20th Apr 2021, 2:09 AM
Makane Santosh
Makane Santosh - avatar
+ 7
Data types are needed so that the compiler can know how the data will be used. To develop a program, there are several types of data that we will study. Among them are Characters, Strings, Array, Numbers and Booleans.
14th Mar 2021, 11:14 AM
Afdhil Yopandi
Afdhil Yopandi - avatar
+ 7
With data types, we can define the usage of the value of a variable.
11th Apr 2021, 10:32 AM
Isuru Jinasena
+ 6
so there can be a difference between "5"+"5"="55" but 5+5=10
17th Apr 2021, 8:31 AM
Karthik
Karthik - avatar
+ 5
The existing answers are pretty good, but the question is incredibly complex despite is simple phrasing. It includes concepts touches compilers, computer design and programming language design. Let me give a short (yes it is) explanation. First of all, don't forget that computers are just (really) dumb circuits (their engineering is ingenious though) that just perform a specific set of operations on blind 0 and 1. Therefore, a way is needed to determine which circuits to use and how to interpret the result. Even in languages that determine the data type automatically (i.e. Python) this is necessary. Otherwise, the result will be non-sense. The computer has to be able to distinguish between data so different intentions of the programmer can be satisfied, e.g.: "1"+"2"="12" whereas 1+2=3. Also, the compiler or the interpreter needs to know how much space is need from the memory. I hope that covers a tiny bit of the answer.
26th Mar 2021, 10:05 PM
Nboumakis
+ 5
Different data types tells what operations can be performed on a particular data. It defines the meaning of the data, and the way values of that type can be stored
18th Apr 2021, 5:25 AM
Devbunny
Devbunny - avatar
+ 5
Data type is noting but type of data which is we can stored in variable
2nd May 2021, 4:21 PM
Sachin S. Kangane
Sachin S. Kangane - avatar
+ 5
Data type is used to Indicate which type of data we store in the variable
16th Jul 2021, 5:03 PM
Neha Choudhari
Neha Choudhari - avatar
+ 5
To declare variables . That would be the best answer
4th Aug 2021, 5:28 AM
Gugan
Gugan - avatar
+ 5
it's important to get exact output
2nd Feb 2022, 4:52 AM
yonas
yonas - avatar
+ 5
A lot of people have given answers already, but just an additional thought is regarding classes. When you start to learn about classes, the different data types begin to make even more sense, as a string is just an object of the string class, and an integer is an object of the integer class. This allows you to access methods that belong specially to that given class, for example, string.lower() doesn't make any sense on an integer. Also using addition (+) operates differently between a string and an integer, as "1" + "1" implies concatenation which gives you "11" whereas 1 + 1 gives you 2 as that means addition for an integer. Hope that helps somebody!
23rd Jul 2022, 9:33 AM
Richard Feather
Richard Feather - avatar
+ 5
We use data type to allocate a proper place for our data. Based on our requirements we can initialize our variable with proper data type. For example if we want to perform simple operations like addition and subtraction we can easily store our result in integer datatype..but while performing division integer datatype may not provide accurate result..at this time we need to change the datatype. That's why we use data type ...just to provide accurate results and store data based on our requirements.
29th Sep 2022, 2:32 PM
BHUMISHREE PATIL
BHUMISHREE PATIL - avatar
+ 4
data types are used to seperate print letters from variables and numbers
16th Mar 2021, 11:51 PM
Steven Whitacre