What is Variables in python and its Types

Programming में variable एक बहुत basic concept है। Variable memory में stored किसी value का नाम होता है।
सरल शब्दों में, variable एक ऐसा नाम है जिसकी मदद से हम data को store करते हैं और बाद में program में use करते हैं।

जब हम किसी value को किसी नाम के साथ assign करते हैं, तो वह नाम variable बन जाता है।

जैसे:

x = 10
name = "Vedant"
price = 99.5

यहाँ:

  • x एक variable है
  • name एक variable है
  • price भी एक variable है

इन variables में अलग-अलग values store की गई हैं।

Variable का काम क्या होता है

Variable का मुख्य काम data को store करना होता है।
Program के दौरान हमें numbers, text, true-false values और दूसरी information को memory में रखना पड़ता है।
इसीलिए variable programming की foundation माने जाते हैं।

उदाहरण के लिए:

age = 20
city = "Patna"

यहाँ:

  • age में 20 store है
  • city में "Patna" store है

बाद में program में इन्हीं names का use करके value access की जाती है।

Variable Types क्या होते हैं

Program में हर value same nature की नहीं होती।
कुछ values whole number होती हैं, कुछ decimal, कुछ text, और कुछ true-false type की होती हैं।
इन्हीं अलग-अलग प्रकार की values को variable types या data types कहा जाता है।

Python में beginners level पर चार basic variable types सबसे important होते हैं:

  • Integer
  • Float
  • String
  • Boolean

Integer Type

Integer type whole numbers को represent करता है।
इसमें decimal part नहीं होता।

Example

x = 25
y = -8
z = 0

यहाँ सभी values integer हैं।

Integer type का use age, marks, quantity, counting जैसी values के लिए किया जाता है।

Float Type

Float type decimal values को store करता है।
जब number में fractional या decimal part हो, तब वह float type होता है।

Example

pi = 3.14
price = 99.5
temperature = 36.6

यहाँ सभी values float हैं।

Float type का use measurements, price, percentage, scientific values जैसी situations में होता है।

String Type

String text data को represent करता है।
जो value quotes के अंदर लिखी जाती है, वह string मानी जाती है।

Example

name = "Python"
city = "Delhi"
message = "Hello"

यहाँ "Python", "Delhi" और "Hello" strings हैं।

String type का use names, messages, text input, addresses जैसी values के लिए होता है।

Boolean Type

Boolean type केवल दो values को represent करता है:

  • True
  • False

यह type logical conditions और decision making में use होता है।

Example

status = True
result = False

यहाँ status और result boolean variables हैं।

Python type खुद कैसे समझता है

Python एक dynamic language है।
इसका मतलब है कि variable का type अलग से declare नहीं करना पड़ता।
जैसे ही value assign होती है, Python खुद उसका type समझ लेता है।

Example

x = 10
name = "Ravi"
price = 45.5
passed = True

यहाँ Python automatically समझ लेता है कि:

  • x integer है
  • name string है
  • price float है
  • passed boolean है

Type check कैसे करें

किसी variable का type check करने के लिए type() function use किया जाता है।

Example

x = 10
print(type(x))

Output:

<class 'int'>

इसी तरह string, float और boolean का type भी check किया जा सकता है।

छोटा example

a = 5
b = 3.5
name = "Vedant"
passed = Trueprint(a)
print(b)
print(name)
print(passed)

यह program दिखाता है कि अलग-अलग प्रकार के variables एक साथ कैसे use होते हैं।

इस topic की मुख्य बात

Variable memory में stored value का नाम होता है।
Python में basic variable types हैं:

  • Integer → whole number
  • Float → decimal number
  • String → text
  • Boolean → True / False

यही types आगे programming के सभी बड़े topics की foundation बनाते हैं।

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top