+ 26
Why we are use data type
318 odpowiedzi
+ 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
+ 86
Data types are used to specify what type of value will be stored in variable
+ 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
+ 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.
+ 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.
+ 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.
+ 8
you need it to know the conversation,
+ 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..
+ 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.
+ 6
so there can be a difference between
"5"+"5"="55"
but
5+5=10
+ 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.
+ 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
+ 5
Data type is noting but type of data which is we can stored in variable
+ 5
Data type is used to Indicate which type of data we store in the variable
+ 5
To declare variables . That would be the best answer
+ 5
it's important to get exact output
+ 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!
+ 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.
+ 4
data types are used to seperate print letters from variables and numbers