If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
Programming में Data Type बहुत ही important concept है। क्योंकि Data Type के according ही हम किसी variable के लिए logic implement करते हैं।
Data Type का simply मतलब है किसी variable का type, जिससे हमें पता चल सके कि कोई variable किस type की value hold किये हुए है , या in future किस type की value hold करेगा।
❕ Important
Data Type के case में Python बहुत ही flexible language है , अगर आपको Java या C की थोड़ी भी knowledge है तो आपको याद होगा कि किसी भी तरह के variable को define करने से पहले हमें उस variable का Data Type define करना पड़ता था। मतलब हमें variable define करते समय ये बताना पड़ता था कि वह variable किस type की value store करने जा रहा है।
Python में किसी भी variable का type किसी programmer द्वारा नहीं किया जा सकता है , यह runtime में ही assign की गयी value के according decide होता है कि variable किस type का है। means हमें variable define करते समय Data Type define नहीं करना पड़ता है , हम directly उस value को assign कर देते हैं।
For Example -
name = "Rahul Kumar"
Python में built in Data Types कुछ प्रकार हैं -
Data Types |
---|
Text : str |
Numeric : int, float, complex |
Sequence : list, tuple, range |
Binary : bytes, bytearray, memoryview |
Mapping : dict |
Set : set, frozenset |
Boolean : bool |
Python में किसी भी variable की Data Type जानने के लिए type() function का use किया जाता है।
age = 90
name = 'Some Name'
print(type(age))
print(type(name))
C:\Users\Rahulkumar\Desktop\python>python data_type.py <class 'int'> <class 'str'>
Numeric में सभी numeric values होती है जिन पर हम arithmetic operations perform कर सकें। इसमें भी तीन तरह की values होती हैं -
int_var1 = 90
int_var2 = -10
float_var1 = 34.90
float_var2 = -134.00
complex_var1 = 4j
complex_var2 = -50j
print(type(int_var1))
print(type(int_var2))
print(type(float_var1))
print(type(float_var2))
print(type(complex_var1))
print(type(complex_var2))
C:\Users\Rahulkumar\Desktop\python>python py_numeric_type.py <class 'int'> <class 'int'> <class 'float'> <class 'float'> <class 'complex'> <class 'complex'>
String में सभी single या double quoted values आती हैं।
Example -
str_var1 = 'Single Quoted'
str_var2 = "Double Quoted"
str_var3 = """multiline
String"""
print(type(str_var1))
print(type(str_var2))
print(type(str_var3))
C:\Users\Rahulkumar\Desktop\python>python py_numeric_type.py <class 'str'> <class 'str'> <class 'str'>
Boolean में सिर्फ दो values True , False होती हैं।
For Example -
bool_var1 = True
bool_var2 = False
print(type(bool_var1))
print(type(bool_var2))
C:\Users\Rahulkumar\Desktop\python>python py_bool_type.py <class 'bool'> <class 'bool'>
Sequence Type में basically बो सभी types होते हैं जिनमे एक से अधिक values store होती हैं like : list, tuple, range
जहाँ एक से अधिक values को key - value pair में store करते हैं।:dictionary
Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)
Get connected with me. :) LinkedIn Twitter Instagram Facebook