2026 में पायथन साक्षात्कार प्रश्न बुनियादी सिंटैक्स से लेकर उन्नत एसिंक पैटर्न, डेटा संरचना और ओओपी डिज़ाइन तक सब कुछ कवर करते हैं। चाहे आप कनिष्ठ डेवलपर भूमिका के लिए तैयारी कर रहे हों या FAANG कंपनी में वरिष्ठ पद के लिए, यह मार्गदर्शिका स्पष्ट, संक्षिप्त उत्तरों के साथ सबसे अधिक पूछे जाने वाले पायथन साक्षात्कार प्रश्नों को शामिल करती है।
📋 Table of Contents
कोर पायथन प्रश्न
1. सूची और टुपल के बीच क्या अंतर है?
सूचियोंपरिवर्तनशील हैं – तत्वों को जोड़ा, हटाया या बदला जा सकता है।टुपल्सअपरिवर्तनीय हैं – एक बार निर्मित होने के बाद, उन्हें संशोधित नहीं किया जा सकता है।
# List — mutable
my_list = [1, 2, 3]
my_list.append(4) # OK
my_list[0] = 10 # OK
# Tuple — immutable
my_tuple = (1, 2, 3)
# my_tuple[0] = 10 # TypeError!
# Tuples are faster and use less memory
# Use tuples for heterogeneous data (coordinates, RGB)
# Use lists for homogeneous, modifiable sequences
# Named tuples — readable tuples
from collections import namedtuple
Point = namedtuple('Point', ['x', 'y'])
p = Point(3, 4)
print(p.x, p.y) # 3 4
2. पायथन के जीआईएल (ग्लोबल इंटरप्रेटर लॉक) की व्याख्या करें
जीआईएल एक म्यूटेक्स है जो मल्टी-कोर सिस्टम पर भी एक समय में केवल एक थ्रेड को पायथन बाइटकोड निष्पादित करने की अनुमति देता है। इसका मतलब है कि पायथन थ्रेड्स पायथन कोड के लिए सही सीपीयू समानता प्राप्त नहीं कर सकते हैं।
- थ्रेड्स I/O संचालन (नेटवर्क, डिस्क) के दौरान GIL जारी करते हैं – इसलिए थ्रेडिंग I/O-बाउंड कार्यों के लिए काम करता है
- सीपीयू-बाउंड समानता के लिए, उपयोग करें
multiprocessing(प्रत्येक प्रक्रिया की अपनी GIL होती है) - पायथन 3.13+ में प्रायोगिक फ्री-थ्रेडेड मोड है (जीआईएल को अक्षम किया जा सकता है)
3. डेकोरेटर क्या हैं? एक उदाहरण दीजिए.
import functools, time
def timer(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
start = time.perf_counter()
result = func(*args, **kwargs)
elapsed = time.perf_counter() - start
print(f"{func.__name__}: {elapsed*1000:.2f}ms")
return result
return wrapper
@timer
def slow_function():
time.sleep(0.1)
return 42
slow_function() # "slow_function: 100.12ms"
4. *आर्ग्स और **क्वार्ग्स के बीच क्या अंतर है?
def func(*args, **kwargs):
print(args) # tuple of positional arguments
print(kwargs) # dict of keyword arguments
func(1, 2, 3, name="Alice", age=30)
# (1, 2, 3)
# {'name': 'Alice', 'age': 30}
# Unpacking
def add(a, b, c): return a + b + c
numbers = [1, 2, 3]
print(add(*numbers)) # 6
settings = {"a": 1, "b": 2, "c": 3}
print(add(**settings)) # 6
5. जनरेटर क्या है और आप इसका उपयोग कब करेंगे?
# Generator — lazy evaluation, memory efficient
def fibonacci():
a, b = 0, 1
while True:
yield a
a, b = b, a + b
# vs list — loads everything into memory
fib = fibonacci()
print([next(fib) for _ in range(10)])
# Use generators when:
# 1. Processing large datasets (files, DB rows)
# 2. Infinite sequences
# 3. Building pipelines
ओओपी प्रश्न
6. @classmethod और @staticmethod के बीच क्या अंतर है?
class Circle:
pi = 3.14159
def __init__(self, radius):
self.radius = radius
# Regular method — receives instance (self)
def area(self):
return self.pi * self.radius ** 2
# classmethod — receives class (cls), can access class variables
@classmethod
def from_diameter(cls, diameter):
return cls(diameter / 2) # factory method
# staticmethod — receives nothing, utility function
@staticmethod
def is_valid_radius(radius):
return radius > 0
c1 = Circle(5)
c2 = Circle.from_diameter(10)
print(Circle.is_valid_radius(-1)) # False
7. एमआरओ (विधि समाधान आदेश) समझाएं
class A:
def method(self): return "A"
class B(A):
def method(self): return "B"
class C(A):
def method(self): return "C"
class D(B, C): # Multiple inheritance
pass
d = D()
print(d.method()) # "B" — follows MRO
print(D.__mro__) # (D, B, C, A, object)
# Python uses C3 linearization for MRO
उन्नत प्रश्न
8. पायथन का मेमोरी प्रबंधन कैसे काम करता है?
- संदर्भ गिनती– प्रत्येक ऑब्जेक्ट ट्रैक करता है कि कितने संदर्भ उसकी ओर इशारा करते हैं
- जब गिनती 0 तक पहुंचती है, तो वस्तु तुरंत मुक्त हो जाती है
- मल जमा करना– परिपत्र संदर्भों को संभालता है (संदर्भ गिनती नहीं हो सकती)
gc.collect()– कचरा संग्रहण को मैन्युअल रूप से ट्रिगर करें- होना शामिल– छोटे पूर्णांक (-5 से 256) और छोटे तार कैश किए जाते हैं
9. उथली और गहरी प्रतिलिपि में क्या अंतर है?
import copy
original = [[1, 2, 3], [4, 5, 6]]
# Shallow copy — new list, but nested objects are shared
shallow = copy.copy(original) # or list(original) or original[:]
shallow[0].append(99)
print(original[0]) # [1, 2, 3, 99] — MODIFIED! (shared reference)
# Deep copy — completely independent copy
deep = copy.deepcopy(original)
deep[0].append(88)
print(original[0]) # [1, 2, 3] — unchanged
10. पायथन की अंतर्निहित डेटा संरचनाएं और उनकी समय जटिलताएं क्या हैं?
| संचालन | सूची | हुक्म | set | डेक |
|---|---|---|---|---|
| पहुँच | हे(1) | ओ(1) औसत | N/A | पर) |
| खोज | पर) | ओ(1) औसत | ओ(1) औसत | पर) |
| सम्मिलित करें (अंत) | हे(1) मूल्यह्रास | ओ(1) औसत | ओ(1) औसत | हे(1) |
| सम्मिलित करें (प्रारंभ करें) | पर) | N/A | N/A | हे(1) |
| मिटाना | पर) | ओ(1) औसत | ओ(1) औसत | हे(1) |
एसिंक प्रश्न
11. asyncio.gather() और asyncio.TaskGroup के बीच क्या अंतर है?
import asyncio
# asyncio.gather — partial failures possible
async def example_gather():
results = await asyncio.gather(
task1(),
task2(),
return_exceptions=True # don't cancel others on failure
)
# Results include exceptions if return_exceptions=True
# asyncio.TaskGroup (Python 3.11+) — all-or-nothing
async def example_task_group():
async with asyncio.TaskGroup() as tg:
t1 = tg.create_task(task1())
t2 = tg.create_task(task2())
# If any task raises, all are cancelled — structured concurrency
asyncio.run(example_task_group())
पायथन साक्षात्कार में सफलता केवल उत्तर याद रखने से नहीं, बल्कि भाषा को गहराई से समझने से मिलती है। प्रत्येक अवधारणा के पीछे “क्यों” पर ध्यान दें – जीआईएल क्यों मौजूद है, जनरेटर मेमोरी-कुशल क्यों हैं, गहरी प्रतिलिपि क्यों मायने रखती है। ट्रेड-ऑफ़ समझाएं और प्रत्येक अवधारणा का वास्तविक दुनिया में अनुप्रयोग दिखाएं।
🔗 Share this article
✍️ Leave a Comment