Python Keywords in Hindi In Python Programming
Python ek bahut hi powerful aur simple programming language hai jo beginners aur experts dono ke liye suitable hai. Is article mein hum Python keywords in Hindi ke baare mein detail mein discuss karenge. Yeh keywords Python programming ke essential parts hain aur inke bina Python code likhna mushkil hai. Keywords predefined words hote hain jo Python ko samjhane mein madad karte hain ki aapka code kya perform karna chah raha hai. So Lets Learn Python Keywords in Hindi:
Keywords Kya Hote Hain?
Python Keywords in Hindi: Python keywords special reserved words hote hain jo Python interpreter ko batate hain ki kaunsa specific function perform karna hai. Yeh keywords change nahi kiye ja sakte aur inhe variables, function names, ya identifiers ke roop mein use nahi kiya ja sakta. Agar aap inhe use karte hain, to interpreter error throw karta hai.
यह भी पढ़ें: 250+ Free Python Projects with Source Code: From Beginner to Advanced
Python Keywords List
Python mein total 35 keywords hote hain. In sabhi keywords ka apna unique use aur significance hota hai. Aap keyword module ka use karke Python ke sabhi keywords ki list print kar sakte hain:
import keyword
print(keyword.kwlist)
Is code ka output kuch is prakar hoga:
['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
Ab hum in keywords ke baare mein detail mein janenge.
List of Keywords in Python Programming
1. False / True: Python Keywords
Yeh dono hi Boolean values hain jo ki logical operations mein use hoti hain. False ka matlab hota hai jhooth aur True ka matlab hota hai sach.
print(True) # Output: True
print(False) # Output: False
2. None: Python Keywords
Yeh keyword ek null value ko represent karta hai. Jab kisi variable ko koi value assign nahi ki jati to usse None assign hoti hai.
a = None
print(a) # Output: None
3. and: Python Keywords
Yeh logical operator hota hai jo ensure karta hai ki dono conditions true honi chahiye.
print(5 > 3 and 3 > 2) # Output: True
print(5 > 3 and 3 < 2) # Output: False
4. or: Python Keywords
Yeh bhi ek logical operator hai jo ensure karta hai ki do conditions me se ek condition true honi chahiye.
print(5 > 3 or 3 < 2) # Output: True
print(5 < 3 or 3 < 2) # Output: False
5. break: Python Keywords
Yeh keyword loop ko exit karne ke liye use hota hai.
for i in range(10):
if i == 5:
break
print(i) # Output: 0 1 2 3 4
6. class: Python Keywords
Iska use ek nayi class define karne ke liye hota hai.
class MyClass:
def my_method(self):
print("Hello from MyClass")
obj = MyClass()
obj.my_method() # Output: Hello from MyClass
7. continue: Python Keywords
Yeh keyword current iteration ko skip kar deta hai aur loop ke next iteration par chala jata hai.
for i in range(10):
if i == 5:
continue
print(i) # Output: 0 1 2 3 4 6 7 8 9
8. def: Python Keywords
Yeh keyword ek nayi function define karne ke liye use hota hai.
def my_function():
print("Hello from my_function")
my_function() # Output: Hello from my_function
9. if: Python Keywords
Yeh keyword condition ko check karne ke liye use hota hai. Agar condition true hoti hai to block execute hota hai.
if 5 > 3:
print("5 is greater than 3") # Output: 5 is greater than 3
10. else: Python Keywords
Yeh keyword if statement ke sath use hota hai. Agar if condition false hoti hai to else block execute hota hai.
if 5 < 3:
print("5 is less than 3")
else:
print("5 is not less than 3") # Output: 5 is not less than 3
11. try: Python Keywords
Yeh keyword exception handling ke liye use hota hai. Isme aap wo code likhte hain jisme exception aane ki sambhavnaye hoti hain.
try:
a = 1 / 0
except ZeroDivisionError:
print("Division by zero is not allowed") # Output: Division by zero is not allowed
12. except: Python Keywords
Yeh try ke sath use hota hai. Exception aane par yeh block execute hota hai.
13. finally: Python Keywords
Yeh block try aur except ke baad execute hota hai. Yeh exception aaye ya na aaye, dono cases mein run hota hai.
try:
a = 1 / 0
except ZeroDivisionError:
print("Division by zero is not allowed")
finally:
print("This is the finally block") # Output: This is the finally block
14. import: Python Keywords
Yeh keyword kisi module ko import karne ke liye use hota hai.
import math
print(math.sqrt(16)) # Output: 4.0
15. for: Python Keywords
Yeh keyword loop define karne ke liye use hota hai. Yeh sequence ke har element ko iterate karta hai.
for i in range(5):
print(i) # Output: 0 1 2 3 4
16. while: Python Keywords
Yeh keyword tab tak loop chalata hai jab tak condition true hoti hai.
i = 0
while i < 5:
print(i)
i += 1 # Output: 0 1 2 3 4
17. lambda: Python Keywords
Yeh keyword anonymous functions ko define karne ke liye use hota hai.
square = lambda x: x * x
print(square(5)) # Output: 25
18. return: Python Keywords
Yeh keyword function se value return karne ke liye use hota hai.
def add(a, b):
return a + b
print(add(5, 3)) # Output: 8
19. nonlocal: Python Keywords
Yeh keyword nested functions mein outer function ke variable ko refer karne ke liye use hota hai.
def outer():
x = "local"
def inner():
nonlocal x
x = "nonlocal"
print("inner:", x)
inner()
print("outer:", x)
outer()
# Output:
# inner: nonlocal
# outer: nonlocal
20. global: Python Keywords
Yeh keyword function ke andar global variable ko modify karne ke liye use hota hai.
x = "global"
def my_function():
global x
x = "modified global"
print("inside:", x)
my_function()
print("outside:", x)
# Output:
# inside: modified global
# outside: modified global
21. pass: Python Keywords
Yeh null statement hota hai jo kuch nahi karta. Yeh placeholder ke roop mein use hota hai.
def my_function():
pass
22. del: Python Keywords
Yeh keyword kisi object ko delete karne ke liye use hota hai.
a = 10
del a
# print(a) # This will raise an error because 'a' is deleted
23. is: Python Keywords
Yeh operator identity comparison ke liye use hota hai.
a = [1, 2, 3]
b = a
print(a is b) # Output: True
print(a == b) # Output: True
24. in: Python Keywords
Yeh keyword membership check karne ke liye use hota hai.
a = [1, 2, 3]
print(2 in a) # Output: True
print(4 in a) # Output: False
25. raise: Python Keywords
Yeh keyword exception ko explicitly raise karne ke liye use hota hai.
def check_age(age):
if age < 18:
raise ValueError("Age must be 18 or above")
return "Access granted"
try:
print(check_age(15))
except ValueError as e:
print(e) # Output: Age must be 18 or above
26. assert: Python Keywords
Yeh keyword debugging ke liye use hota hai. Yeh condition check karta hai aur agar condition false hoti hai to AssertionError raise karta hai.
assert 5 > 3 # No output, as the condition is true
assert 5 < 3 # This will raise an AssertionError
27. async / await: Python Keywords
Yeh keywords asynchronous programming ke liye use hote hain. Yeh concurrent programming ko simplify karte hain.
import asyncio
async def main():
print("Hello")
await asyncio.sleep(1)
print("World")
asyncio.run(main())
28. from: Python Keywords
Yeh keyword module se specific functions ya classes import karne ke liye use hota hai.
from math import sqrt
print(sqrt(16)) # Output: 4.0
29. with: Python Keywords
Yeh keyword context management ke liye use hota hai, jaise file handling. Yeh ensure karta hai ki resources properly close ho jaye.
with open("textfile.txt", "w") as file:
file.write("Hello World")
30. yield: Python Keywords
Yeh keyword generator functions banane ke liye use hota hai. Yeh function ko suspend karta hai aur wapas resume karta hai.
def generator():
yield 1
yield 2
yield 3
for value in generator():
print(value)
# Output:
# 1
# 2
# 3
Python Programming in Hindi: Conclusion
Python programming in Hindi ko samajhna ab aasan hai kyunki humne Python ke sabhi essential keywords ko detail mein cover kiya hai. Yeh keywords Python programming ka foundation hain aur inke bina code likhna possible nahi hai. In keywords ko achhe se samajhna aur inka sahi tarike se use karna successful Python programmer banne ke liye zaroori hai.
Is article mein humne Python keywords in Hindi ka detail review kiya. Yeh keywords Python ke predefined words hain jinhe variables, functions ya class names ke roop mein use nahi kiya ja sakta. Keywords jaise ki 'if', 'else', 'for', 'while', 'def', 'class', 'try', 'except', 'finally', 'import', 'from', 'with', 'lambda', 'yield' etc. Python programming ko asan aur efficient banate hain.
Agar aap Python programming seekhne ke shuruat kar rahe hain to in keywords ka achhi tarah se samajh aur practice karna aapke liye faydemand hoga.
यह भी पढ़ें: Python Programming In Hindi | Python Tutorials In Hindi