Feedback Form

Variables, Data Types in python in hindi in hindi

Variables and Data Types in Python (Complete Guide in Hindi)

Variables and Data Types in Python in Hindi

Python programming सीखने की शुरुआत करते समय सबसे पहला और सबसे ज़रूरी topic होता है Variables and Data Types in Python। College exams, competitive exams और practical programming — हर जगह यही base बनता है। अगर आपको Variables और Data Types clear नहीं हैं, तो आगे के concepts समझना मुश्किल हो जाता है।

इस part में हम Python के Variables और basic Data Types को बिल्कुल classroom style में, simple हिंदी में समझेंगे। जहाँ ज़रूरत होगी वहाँ English terms use होंगी ताकि exam-oriented understanding strong बने।

What is Variable in Python

Python में Variable एक ऐसा नाम होता है जिसमें हम कोई value store करते हैं। Simple शब्दों में, Variable एक container की तरह होता है जिसमें data रखा जाता है।

जब program run होता है, तब variable memory में किसी value को point करता है। Python में variable declare करने के लिए हमें data type अलग से नहीं लिखना पड़ता, क्योंकि Python एक dynamically typed language है।

Example के लिए, जब हम किसी student का marks store करना चाहते हैं, तो हम एक variable बना सकते हैं और उसमें value assign कर सकते हैं।

marks = 85

यहाँ marks variable है और 85 उसकी value है। Python automatically समझ लेता है कि 85 एक integer है।

Python Variable Naming Rules

Python में variable बनाते समय कुछ rules follow करना बहुत ज़रूरी है, क्योंकि exam में अक्सर इन पर direct questions पूछे जाते हैं।

  • Variable का नाम letter या underscore (_) से शुरू होना चाहिए
  • Variable name में numbers हो सकते हैं, लेकिन शुरुआत number से नहीं हो सकती
  • Spaces allowed नहीं हैं, words को underscore से जोड़ते हैं
  • Python के keywords को variable name नहीं बना सकते

Correct और incorrect variable names को समझना बहुत important है।

Valid Variable Invalid Variable
student_name student name
totalMarks 1marks
_result class

Exam point of view से, variable naming rules को याद रखना बहुत ज़रूरी है क्योंकि MCQ और short answer दोनों में यह topic आता है।

What are Data Types in Python

Data Types in Python यह बताते हैं कि variable के अंदर किस तरह का data store है। हर data type का अपना behavior और usage होता है।

Python में data type automatically assign होता है, लेकिन programmer को यह पता होना चाहिए कि कौन सा data किस type का है।

Example के लिए, number, text, true/false — ये सब अलग-अलग data types हैं। Python में data types programming logic और memory management में बहुत important role निभाते हैं।

Types of Data Types in Python

Python में कई तरह के Data Types होते हैं, लेकिन college level और basic programming के लिए कुछ मुख्य data types ही ज़्यादा important होते हैं।

इन data types को समझना आगे loops, functions और data structures सीखने के लिए base तैयार करता है।

  • Numeric Data Types
  • String Data Type
  • List Data Type
  • Tuple Data Type
  • Set Data Type
  • Dictionary Data Type
  • Boolean Data Type
  • None Data Type

Numeric Data Types in Python

Numeric Data Types का use numbers store करने के लिए किया जाता है। Python में numbers के लिए अलग-अलग numeric data types available हैं।

Main numeric data types हैं: int, float और complex। इनका use calculation और mathematical operations में होता है।

a = 10 b = 3.5 c = 2 + 4j

यहाँ a integer है, b float है और c complex number है। Exam में अक्सर पूछा जाता है कि Python में numeric data types कौन-कौन से होते हैं।

String Data Type in Python

String Data Type का use text store करने के लिए किया जाता है। Python में string हमेशा quotes के अंदर लिखी जाती है।

Single quotes और double quotes दोनों valid हैं। String का use names, messages और text data store करने के लिए होता है।

name = "Ramesh" message = 'Welcome to Python'

Python में string immutable होती है, यानी एक बार string बन जाने के बाद उसके characters को directly change नहीं किया जा सकता।

College exams में string related questions बहुत common होते हैं, इसलिए इसका clear concept होना ज़रूरी है।

List Data Type in Python

List Data Type Python का एक बहुत ही important और frequently used data type है। List का use multiple values को एक ही variable में store करने के लिए किया जाता है।

List ordered होती है, यानी इसमें data उसी sequence में रहता है जिस sequence में हमने डाला होता है। List mutable होती है, मतलब हम इसमें data add, remove या change कर सकते हैं।

marks = [45, 67, 89, 72]

यहाँ marks एक list है जिसमें चार integer values store हैं। College exams में list से related questions बहुत पूछे जाते हैं क्योंकि यह real-life data handling में काम आती है।

List का use तब किया जाता है जब हमें similar type या different type के data को group में रखना हो। Python की flexibility यही है कि एक list में अलग-अलग data types भी रखे जा सकते हैं।

Tuple Data Type in Python

Tuple Data Type दिखने में list जैसा ही होता है, लेकिन सबसे बड़ा difference यह है कि tuple immutable होता है।

Immutable का मतलब है कि tuple बनने के बाद उसमें कोई change नहीं किया जा सकता। Tuple round brackets () में लिखा जाता है।

subjects = ("Maths", "Physics", "Chemistry")

यहाँ subjects एक tuple है। Tuple का use तब किया जाता है जब data को सुरक्षित रखना हो और accidental changes से बचाना हो।

Exam point of view से, list और tuple के बीच difference बहुत important topic है। Short notes और comparison questions में यह अक्सर आता है।

Set Data Type in Python

Set Data Type unordered collection होता है, यानी इसमें elements का कोई fixed order नहीं होता। Set की सबसे खास बात यह है कि इसमें duplicate values allowed नहीं होतीं।

Set curly brackets {} में लिखा जाता है। यह mathematical set की तरह behave करता है।

roll_numbers = {101, 102, 103, 101}

यहाँ duplicate value automatically remove हो जाएगी। Final set में हर value unique होगी।

Set का use mostly uniqueness check करने और mathematical operations जैसे union, intersection के लिए किया जाता है। College syllabus में set basic level पर पूछा जाता है।

Dictionary Data Type in Python

Dictionary Data Type key-value pair में data store करता है। हर value एक unique key से जुड़ी होती है।

Dictionary unordered होती है और curly brackets {} में लिखी जाती है। Key और value के बीच colon (:) use किया जाता है।

student = { "name": "Amit", "roll": 21, "marks": 78 }

यहाँ student dictionary है जिसमें हर data एक key से linked है। Dictionary real-life data representation के लिए बहुत useful होती है।

College exams में dictionary से related theory questions और simple programs दोनों आते हैं। इसलिए इसका clear concept होना ज़रूरी है।

Boolean Data Type in Python

Boolean Data Type सिर्फ दो values store करता है: True और False। Boolean data type logical conditions और decision making में use होता है।

Python में Boolean का use comparison और conditional statements में किया जाता है।

is_pass = True result = False

Boolean data type control flow को समझने के लिए बहुत important है। If-else और loops में Boolean condition ही decide करती है कि code चलेगा या नहीं।

Exam में Boolean expressions और output based questions काफी common होते हैं।

None Data Type in Python

None Data Type Python में empty value को represent करता है। जब variable में कोई value assign नहीं होती, तब None का use किया जाता है।

None का मतलब zero या empty string नहीं होता, बल्कि यह बताता है कि variable में अभी कोई value नहीं है।

result = None

None data type function return value और default initialization में बहुत useful होता है। Advanced topics में इसका use और भी ज़्यादा देखने को मिलता है।

Difference Between List, Tuple and Set

College exams में अक्सर list, tuple और set के बीच difference पूछा जाता है। इसलिए इनका comparison समझना बहुत ज़रूरी है।

Feature List Tuple Set
Order Ordered Ordered Unordered
Mutable Yes No Yes
Duplicates Allowed Allowed Not Allowed

यह table exam revision के लिए बहुत helpful है। One-mark और two-mark questions में यही differences पूछे जाते हैं।

Why Variables and Data Types are Important in Python

Variables और Data Types Python programming की foundation हैं। बिना इनके programming logic develop करना possible नहीं है।

Data type सही न समझने पर program गलत output दे सकता है। Variables के सही use से code readable और efficient बनता है।

College level से लेकर competitive exams तक, हर syllabus में Variables and Data Types in Python mandatory topic होता है। इसलिए इस chapter को strong बनाना बहुत ज़रूरी है।

अगर ये concepts clear हैं, तो loops, functions, file handling और data structures समझना बहुत आसान हो जाता है।

FAQs

Python में Variable एक नाम होता है जिसका उपयोग किसी value को store करने के लिए किया जाता है। Variable memory location को represent करता है जहाँ data रखा जाता है। Python dynamically typed language है, इसलिए variable declare करते समय data type लिखने की जरूरत नहीं होती।

Python में Data Types यह बताते हैं कि variable के अंदर किस प्रकार का data store है। Data Types program को यह समझने में मदद करते हैं कि data पर कौन सा operation possible है। Python में common data types जैसे int, float, string, list, tuple, set, dictionary, boolean और None होते हैं।

Python में Variable declare करना बहुत simple है। आपको सिर्फ variable name लिखकर उसमें value assign करनी होती है। Example: a = 10 यहाँ a variable है और 10 उसकी value है।

List और Tuple दोनों multiple values store करने के लिए use होते हैं। List mutable होती है यानी इसमें changes किए जा सकते हैं, जबकि Tuple immutable होती है। Exam में List vs Tuple का difference एक बहुत important question माना जाता है।

Python में Dictionary एक data type है जो data को key-value pair में store करता है। Dictionary का use तब किया जाता है जब हमें structured और meaningful data store करना हो। Real-life examples जैसे student details Dictionary के through आसानी से represent किए जाते हैं।

Boolean Data Type True और False values store करता है और logical conditions में use होता है। None Data Type empty value को represent करता है जब variable में कोई data assign नहीं होता। Conditional statements और functions में ये दोनों data types बहुत important role निभाते हैं।