Why we are use data type | Sololearn: Learn to code for FREE!

+12

Why we are use data type

3/23/2020 5:36:29 AM

Chaitanya Dnyaneshwar Kuwar

217 Answers

New Answer

+278

So there can be a difference between "2" + "2" = "22" And 2 + 2 = 4

+147

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

+70

Data types are used to specify what type of value will be stored in variable

+29

Data type are used for different type of data Integer for addition 4+5= 9 String for concatenation "4"+"5"= 45 "Num"+"ber"= number

+21

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.

+14

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.

+9

you need it to know the conversation,

+9

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.

+9

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..

+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.

+7

With data types, we can define the usage of the value of a variable.

+5

so there can be a difference between "5"+"5"="55" but 5+5=10

+5

Data type is noting but type of data which is we can stored in variable

+5

To declare variables . That would be the best answer

+4

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.

+4

Data type is used to Indicate which type of data we store in the variable

+4

it's important to get exact output

+3

data types are used to seperate print letters from variables and numbers

+3

To Specify desire output

+3

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