CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
2
You visited us 2 times! Enjoying our articles? Unlock Full Access!
Question

Which data type will be used to represent the following data values and why?

a) Number of months in a year

b) Resident of Delhi or not

c) Mobile number

d) Pocket money

e) Volume of a sphere

f) Perimeter of a square

g) Name of the student

h) Address of the student

Open in App
Solution

a) The int data type will be used to represent 'Number of months in a year' as it will be an integer i.e. 12.

b) The boolean data type will be used to represent 'Resident of Delhi or not' as a person will be either a resident of Delhi or not a resident of Delhi. Therefore, the values True or False will be sufficient to represent the values.

c) The integer data type will be used to represent 'Mobile number' as it will be a ten-digit integer only.

d) The float data type will be used to represent 'Pocket money' as it can be in decimal. e.g Rs. 250.50 i.e 250 rupees and 50 paise.

e) The float data type will be used to represent 'Volume of a sphere'.
The formula for the volume of a sphere:
Volume of sphere, V=43πr3
Even if 'r' is a whole number, the value of volume can be a fraction which can be represented in a decimal form easily by float data type.

f) The float data type will be used to represent 'Perimeter of a square'.
The perimeter of a square:
Perimeter = 4 × side length
If the side length is a decimal number, the result may come out to be a decimal number which can be easily represented by float data type.

Note:- If the side length is a whole number, the perimeter will always be an integer, however, we should be open to the possibility that the side length can be in decimal as well.

g) The string data type will be used to represent 'Name of the student'.

h)The string data type will be used to represent 'Address of the student'. However, if we have to store the address in a more structured format, we can use dictionary data type as well. e.g. Address = { 'Line1': ‘Address line 1', 'Line2':'Address Line2', 'Locality':'Locality Name', 'City':'City Name', 'Pincode':110001, 'Country':'India'}

flag
Suggest Corrections
thumbs-up
4
similar_icon
Similar questions
View More
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Conversion of Length, Mass and Capacity
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon