Python Variables In Hindi In Python Programming
Introduction to Python Programming In Hindi: Python ek aisi programming language hai jo seekhne aur use karne mein bahut aasan hai. Yeh ek high-level, interpreted, and general-purpose language hai jo beginners aur professionals dono ke liye useful hai. Python ki readability aur simplicity isse software development, web development, data analysis, artificial intelligence, aur scientific computing jaise fields mein popular banati hai. So Lets learn Python Variables In Hindi:
Python Variables In Hindi
Python Variables kisi memory ko diya gaya naam hai jo kisi value ko hold karti hai ya store karti hai. Matlab jab hum Variable define kar rahe hain toh hum memory mein value ko store karke use naam de rahe hote hain. Python mein variables ko define karna bahut simple hai aur iske liye kisi special character ki zaroorat nahi hoti. Simply, variable ko need ke according value assign kar di jati hai.
यह भी पढ़ें: 250+ Free Python Projects with Source Code: From Beginner to Advanced
Python Variable Ka Example
Yahan par hum kuch examples dekhte hain jo Python variables ko demonstrate karte hain.
name = "Unlock Coding"
print(name)
Is code ko run karne par output hoga:
Unlock Coding
Python ek case sensitive language hai matlab koi bhi defined variable sirf usi name se accessible hoga. Matlab agar small letters mein variable define kiya gaya hai toh use capital letters se access nahi kar sakte. Dekhein niche example:
name = "Unlock Coding"
NAME = "UNLOCK CODING"
print(name)
print(NAME)
Is code ka output hoga:
Unlock Coding
UNLOCK CODING
Python Variables Update Karna
Python mein aap apni need ke according kisi bhi type ki value assign kar sakte hain, aur jab chahe us variable ki value ko nai value assign karke update kar sakte hain. Dekhein example:
var = 5
print(var)
# now assign it a new value.
var = 'hello'
print(var)
# again change.
var = True
print(var)
Is code ka output hoga:
5
hello
True
Python Variables Naming Rules
Python mein variables define karte waqt kuch baatein dhyan mein rakhni chahiye jaise:
- Variables ke name kisi alphabet ya underscore (jaise: _name, name) se start hote hain. Variables ke name numbers se start nahi ho sakte hain.
- Variables mein alphabets (A - z), numbers (0 - 9), aur underscore ( _ ) ho sakte hain.
- Python case sensitive hoti hai matlab age aur Age do different variables honge.
Example of Valid and Invalid Variables
# These are invalid
8name = "Unlock"
full-name = "Unlock Coding"
full_name@ = "Unlock Coding"
# These are valid
_name = "Unlock"
full_name = "Unlock Coding"
full_name1 = "Unlock Coding"
Python Defining Multiple Variables
Python mein aap different - different tareeke se sirf ek single line mein multiple variables define kar sakte hain. Dekhein example:
name, age, address = 'Ram Kumar', 25, 'Uttar Pradesh, India'
print(name)
print(age)
print(address)
# You can also extract from a list
name, age, address = ['Ram Kumar', 25, 'Uttar Pradesh, India']
print(name)
print(age)
print(address)
Is code ka output hoga:
Ram Kumar
25
Uttar Pradesh, India
Ram Kumar
25
Uttar Pradesh, India
Python Constants
Baaki languages like PHP, Java, JavaScript ki tarah Python constants ko support nahi karta hai. Python mein variables ko constant banane ka koi built-in tareeka nahi hai, lekin aap naming convention ka use karke constants define kar sakte hain jaisa niche example mein hai:
MAX_SPEED = 120
PI = 3.14159
Variables as Containers
Python mein, ek variable ek container hota hai jo kisi bhi type ka data store kar sakta hai jaise number, string, list, tuple, dictionary, function, ya kisi aur data type ka. Yahan kuch examples hain:
# Number ko variable mein store karna
num = 10
# String ko variable mein store karna
name = "John"
# List ko variable mein store karna
my_list = [1, 2, 3, 4, 5]
In variables ka use aap apni program mein kahi bhi kar sakte hain:
print(num) # 10 ko print karega
print(name) # "John" ko print karega
print(my_list) # [1, 2, 3, 4, 5] ko print karega
Multi-Word Variable Names
Python mein multi-word variable names ko different styles mein likha ja sakta hai:
Camel Case: Pehla word chhota aur har agla word bada hota hai.
fullName = "Unlock Coding"
Pascal Case: Har word bada hota hai.
FullName = "Unlock Coding"
Snake Case: Sabhi words chhote aur underscores se separated hote hain.
full_name = "Unlock Coding"
Assigning Multiple Values to Multiple Variables
Ek hi line mein multiple values ko different variables mein assign karne ke different tareeke hain:
a, b, c = 1, 2, 3
# Alag tareeke se
a = 1
b = 2
c = 3
Assigning a Single Value to Multiple Variables
Ek value ko multiple variables mein assign karne ka tareeka:
x = y = z = 10
# Alag tareeke se
x = 10
y = x
z = x
Variable Scope in Python
Python mein variables ka scope define karta hai ki variable ko program ke kin parts mein access kiya ja sakta hai. Variable do types ke scope mein ho sakte hain: local aur global.
Local Variable: Yeh function ke andar define hote hain aur sirf usi function ke andar accessible hote hain.
def my_function():
x = 10
print(x)
my_function()
# print(x) # This will give an error since x is not accessible outside the function
Global Variable: Yeh function ke bahar define hote hain aur program ke kisi bhi part mein accessible hote hain.
x = 10
def my_function():
print(x)
my_function()
print(x)
Using Global Keyword
Agar aap function ke andar global variable ko modify karna chahte hain toh global keyword ka use kar sakte hain.
x = 10
def my_function():
global x
x = 5
my_function()
print(x) # Output will be 5
Dynamic Typing in Python
Python ek dynamically typed language hai matlab aap ek hi variable mein different types ki values assign kar sakte hain bina kisi type declaration ke.
var = 10
print(type(var)) # Output: <class 'int'>
var = "Hello"
print(type(var)) # Output: <class 'str'>
var = [1, 2, 3]
print(type(var)) # Output: <class 'list'>
Type Casting in Python
Kabhi kabhi humein ek type ki value ko dusre type mein convert karna padta hai. Is process ko type casting kehte hain.
# Integer to String
num = 10
num_str = str(num)
print(type(num_str)) # Output: <class 'str'>
# String to Integer
str_num = "123"
int_num = int(str_num)
print(type(int_num)) # Output: <class 'int'>
# Integer to Float
int_num = 5
float_num = float(int_num)
print(type(float_num)) # Output: <class 'float'>
Python Variables In Hindi: FAQs
Q1: Python variables ka scope kya hota hai?
Python variables ka scope define karta hai ki variable ko program ke kin parts mein access kiya ja sakta hai. Yeh do types ka hota hai: local aur global.
Q2: Python mein variable ko update kaise karte hain?
Python mein variable ko update karna simple hai, aap simply us variable ko new value assign kar dete hain.
Q3: Kya Python case sensitive language hai?
Haan, Python case sensitive language hai, matlab small letters aur capital letters ke variables different treat kiye jaate hain.
Q4: Ek value ko multiple variables mein assign kaise karte hain?
Ek value ko multiple variables mein assign karne ke liye aap is tarah likh sakte hain: x = y = z = 10.
Conclusion
Python variables ko sahi tareeke se samajhna aur use karna Python programming in Hindi mein ek basic aur important step hai. Variables ka use aapko efficient aur readable code likhne mein madad karega. Is article mein humne dekha ki Python variables kaise define kiye jaate hain, unke naming rules kya hain, aur kaise unhe update aur use kiya ja sakta hai. Python ki simplicity aur flexibility isse ek powerful language banati hai jo beginners aur experts dono ke liye useful hai.
Is article ko padne ke baad aapko Python variables in Hindi aur Python programming in Hindi ke baare mein acchi understanding mil gayi hogi. Python seekhne aur use karne mein bahut aasan hai, aur iski flexibility aur power isse programming ke liye ek ideal choice banati hai.
यह भी पढ़ें: Python Programming In Hindi | Python Tutorials In Hindi