1. What is Python?
English:
Python is a high-level, interpreted, general-purpose programming language known for its
readability and simplicity.
Hindi:
Python high-level, interpreted general-purpose programming language
syntax
2. Tell me the areas where Python is being used?
English:
Web Development (Django, Flask)
Data Science and Analytics (Pandas, NumPy)
Machine Learning & AI (TensorFlow, Scikit-learn)
Automation & Scripting
Game Development
Desktop Applications
IoT and Networking
Hindi:
IoT
3. What is high-level and low-level language?
English:
High-Level Language: Easy for humans to understand (e.g., Python, Java)
Low-Level Language: Closer to machine language, hard for humans (e.g., Assembly)
Hindi:
High-Level Language:
Low-Level Language:
4. What is interpreted language?
English:
An interpreted language executes code line-by-line using an interpreter.
Example: Python, JavaScript
Hindi:
Interpreted language line-by-line
Python,
: JavaScript
5. What is compiled language?
English:
A compiled language converts the whole code into machine code before execution.
Example: C, C++
Hindi:
Compiled language ,
C, C++
:
6. What is statically typed language?
English:
In statically typed languages, the variable type is defined at compile-time.
Example: Java, C++
Hindi:
Statically typed language variable type (compile-time )
7. What is dynamically typed language?
English:
In dynamically typed languages, the variable type is decided at runtime.
Example: Python, JavaScript
Hindi:
Dynamically typed language variable type
8. What is weakly typed language?
English:
A weakly typed language allows implicit conversion between unrelated types.
Example: JavaScript
Hindi:
Weakly typed language - data types error
9. What is strongly typed language?
English:
Strongly typed language does not allow operations between incompatible types without explicit
conversion.
Example: Python
Hindi:
Strongly typed language - types operation conversion
10. What is .PYC file (Byte code)?
English:
.pyc file is the compiled bytecode file generated by Python after executing .py files.
Hindi:
.pyc Python compiled bytecode .py
11. What is PVM (Python Virtual Machine)?
English:
PVM reads bytecode (.pyc) and executes it. It is part of Python’s runtime environment.
Hindi:
PVM bytecode Python execution engine
12. How Python internally works?
English:
1.
Code is written in .py file
2.
Python compiles it to bytecode (.pyc)
3.
PVM interprets bytecode line-by-line
Hindi:
1.
.py
2.
Python bytecode
3.
PVM bytecode execute
13. What is PEP 8?
English:
PEP 8 is the Python Enhancement Proposal that defines the coding style guide for Python code.
Hindi:
PEP 8 guideline Python standard
14. What is PIP and its use?
English:
PIP is a package manager for Python used to install and manage external Python libraries.
Hindi:
PIP tool Python libraries install manage
15. What is Bytecode and when is it created?
English:
Bytecode is an intermediate code between source code and machine code. It’s created after
the .py file is compiled.
Hindi:
Bytecode .py compile
16. What is indentation in Python? Does Python rely on
indentation?
English:
Indentation refers to spaces or tabs used at the beginning of a line.
Yes, Python strictly relies on indentation to define code blocks.
Hindi:
Indentation space/tab
Python indentation , code blocks define
17. What is a variable?
English:
A variable is a name that holds a value in memory.
Hindi:
Variable value store
18. What are variable naming rules?
English:
Must begin with a letter or underscore _
Can contain letters, digits, underscore
Cannot be a keyword
Case-sensitive
Hindi:
Variable letter underscore
letters, digits, _
keyword
case-sensitive
19. What is datatype and name of datatypes?
English:
Datatype tells what kind of data a variable holds.
Python Datatypes:
int – Integer
float – Decimal number
str – String
bool – True/False
list, tuple, set, dict, None
Hindi:
Datatype variable
int, float,
: str, bool, list, tuple, set, dict
20. What is keyword in Python?
English:
Keywords are reserved words in Python which have special meaning.
Examples: if, else, def, class, True, False
Hindi:
Keywords Python variable
1. What is __init__?
English:
__init__ is a special method (constructor) in Python classes. It is called automatically when a new
object is created.
Hindi:
__init__ method (constructor) object call
python
CopyEdit
class Student: def __init__(self, name): self.name = name
2. Difference between Python Arrays and Lists?
English:
Array: Only stores same data types.
List: Stores different data types.
Arrays need the array module.
Hindi:
Array: type data store
List: - type data store
Array use array module import
3. How to make a Python Script executable on Unix?
English:
1.
Add this at the top of your .py file:
#!/usr/bin/env python3
2.
Make it executable:
chmod +x script.py
Hindi:
1.
:
#!/usr/bin/env python3
2.
:
chmod +x script.py
4. What is slicing in Python?
English:
Slicing is used to get a part (subset) of a list, string, or tuple.
Syntax: sequence[start:stop:step]
Hindi:
Slicing list, string tuple
python
CopyEdit
s = "Python" print(s[1:4]) # yth
5. What is docstring in Python?
English:
A docstring is a string written just below a function/class to describe its purpose.
Use triple quotes (""" """).
Hindi:
Docstring comment function class
python
CopyEdit
def add(a, b): """This function adds two numbers.""" return a + b
6. What are unit tests in Python?
English:
Unit tests are used to test small parts (units) of code. Python has a unittest module for this.
Hindi:
Unit test - testing
7. What is break, continue, and pass in Python?
English:
break: exits the loop
continue: skips current loop and goes to next
pass: does nothing, used as a placeholder
Hindi:
break:
continue: iteration
pass: ,
8. What is the use of self in Python?
English:
self refers to the current object inside a class. Used to access variables and methods.
Hindi:
self current object represent , class variables methods
9. What are global, protected, and private attributes in
Python?
English:
Global: Accessible everywhere
Protected (_var): Accessible within class and subclass
Private (__var): Accessible only inside the class
Hindi:
Global:
Protected: class subclass
Private: class
10. What are modules and packages in Python?
English:
Module: A .py file containing Python code
Package: A folder containing multiple modules with __init__.py
Hindi:
Module: Python functions classes
Package: modules collection
11. What is pass in Python?
English:
pass is a null statement used when a statement is required but nothing needs to be done.
Hindi:
pass statement code block
12. Common built-in data types in Python?
English:
int, float, complex
str
list, tuple, set, dict
bool, None
Hindi:
Python data types:
int, float:
string: str
collection: list, tuple, set, dict
bool,
: None
13. What are lists and tuples? Difference?
English:
List: Mutable (can be changed), use []
Tuple: Immutable (cannot be changed), use ()
Hindi:
List:
Tuple:
python
CopyEdit
l = [1, 2] t = (1, 2)
14. What is Scope in Python?
English:
Scope defines where a variable can be accessed.
Types: Local, Enclosing, Global, Built-in (LEGB Rule)
Hindi:
Scope variable -
Local,: Enclosing, Global, Built-in
15. What is PEP 8 and why is it important?
English:
PEP 8 is a coding style guide for Python. It helps keep code clean, readable, and consistent.
Hindi:
PEP 8 standard Python
16. What is an Interpreted language?
English:
In interpreted languages, code is executed line-by-line using an interpreter.
Example: Python
Hindi:
Interpreted language line-by-line execute
Python:
17. What is a dynamically typed language?
English:
Variables don’t need to declare type; Python decides type at runtime.
Hindi:
Python run-time variable type
python
CopyEdit
x = 10 # int x = "Hello" # str
18. What is Python?
English:
Python is an easy-to-learn, high-level, interpreted programming language used in many fields like
AI, web development, and automation.
Hindi:
Python high-level,
, interpreted programming language AI, web development,
automation
**Here is a clear and professional explanation of Python Interview Questions for Experienced —
with Hindi + English answers for better understanding.
1. What are Dict and List comprehensions?
English:
List comprehension creates lists in one line using a concise syntax.
Dict comprehension creates dictionaries in one line.
python
CopyEdit
# List squares = [x*x for x in range(5)] # Dict squared_dict = {x: x*x for x in range(5)}
Hindi:
List Dictionary
2. What are decorators in Python?
English:
A decorator is a function that modifies the behavior of another function without changing its
code.
python
CopyEdit
def decorator(func): def wrapper(): print("Before function") func() print("After function") return
wrapper
Hindi:
Decorator function modify , code
3. What is Scope Resolution in Python?
English:
It refers to finding the value of a variable based on its scope (LEGB Rule).
Local Enclosing Global Built-in.
Hindi:
Scope Resolution Python variable value
4. What are Python namespaces? Why are they used?
English:
A namespace is a mapping between names and objects.
Used to avoid name conflicts.
Hindi:
Namespace variable values
5. How is memory managed in Python?
English:
Python uses automatic memory management.
Uses reference counting and garbage collection.
Hindi:
Python memory -- manage , reference counting garbage collector
6. What is lambda in Python? Why is it used?
English:
Lambda is an anonymous, one-line function.
Used for short operations.
python
CopyEdit
add = lambda x, y: x + y
Hindi:
Lambda function
7. Explain how to delete a file in Python?
English:
Use os.remove() from the os module.
python
CopyEdit
import os os.remove("file.txt")
Hindi:
os module remove() function delete
8. What are negative indexes and why are they used?
English:
Negative indexing starts from the end of a list or string.
-1 = last element
Hindi:
Negative index list string access
**9. What does *args and kwargs mean?
English:
*args: Variable number of positional arguments
**kwargs: Variable number of keyword arguments
python
CopyEdit
def func(*args, **kwargs): print(args, kwargs)
Hindi:
*args: values (arguments)
**kwargs: key-value pairs
10. Explain split() and join() functions in Python?
English:
split() breaks a string into a list
join() combines a list into a string
python
CopyEdit
"hello world".split() ['hello', 'world'] '-'.join(['a', 'b']) 'a-b'
Hindi:
split() string list
join() list string
11. What are iterators in Python?
English:
An object with __iter__() and __next__() methods.
Used in loops to fetch one item at a time.
Hindi:
Iterator object - values
12. How are arguments passed — by value or by
reference in Python?
English:
Arguments are passed by object reference.
Mutable types changes reflect; Immutable don’t reflect.
Hindi:
Python arguments reference Mutable object
13. How is Python interpreted?
English:
Python source code compiled to bytecode executed by PVM (Python Virtual Machine)
Hindi:
Python bytecode compile , PVM execute
14. Difference between .py and .pyc files?
English:
.py: Python source file
.pyc: Compiled bytecode file, created automatically
Hindi:
.py = source code
.pyc = compiled file Python
15. What is the use of help() and dir() functions?
English:
help() shows documentation
dir() lists available methods and attributes
Hindi:
help() function
dir() object methods/attributes
16. What is PYTHONPATH in Python?
English:
An environment variable that tells Python where to look for modules/packages.
Hindi:
PYTHONPATH variable Python modules import
17. What are generators in Python?
English:
Generators are iterators created using yield. They save memory and compute values on the fly.
python
CopyEdit
def gen(): yield 1 yield 2
Hindi:
Generators functions value return memory-efficient
18. What is pickling and unpickling?
English:
Pickling: Converting Python object byte stream
Unpickling: Byte stream Python object
python
CopyEdit
import pickle pickle.dump(obj, file) # Pickle pickle.load(file) # Unpickle
Hindi:
Pickling object file store process Unpickling load
19. Difference between xrange and range?
English:
In Python 2: xrange is memory-efficient
In Python 3: Only range exists and behaves like xrange
Hindi:
Python 2 xrange() efficient
Python 3 range() xrange()
20. How do you copy an object in Python?
English:
Use copy module:
copy() for shallow copy
deepcopy() for deep copy
python
CopyEdit
import copy a = [1, 2, [3, 4]] b = copy.deepcopy(a)
Hindi:
Python object copy copy module
**Here are Python OOPs (Object-Oriented Programming) Interview Questions with simple
English + Hindi explanations for freshers and experienced candidates alike.
1. How will you check if a class is a child of another
class?
English:
Use issubclass() function to check if a class is a child (subclass) of another.
python
CopyEdit
class A: pass class B(A): pass print(issubclass(B, A)) # True
Hindi:
issubclass() function class class child
2. What is __init__ method in Python?
English:
It’s the constructor method that runs automatically when an object is created.
It initializes the object’s properties.
Hindi:
__init__() constructor object call
python
CopyEdit
class Student: def __init__(self, name): self.name = name
3. Why is __del__() / finalize used?
English:
__del__() is a destructor method called automatically when an object is about to be destroyed.
Used to release resources.
Hindi:
__del__() destructor object destroy , resources free
4. Differentiate between new and override modifiers.
English:
Python doesn’t have new and override keywords.
But constructor overloading can be done using __new__() and
Method overriding is done by redefining a method in child class.
python
CopyEdit
class A: def show(self): print("A") class B(A): def show(self): print("B") # Overriding
Hindi:
Python new override keywords , method override
5. How is an empty class created in Python?
English:
Use pass keyword.
python
CopyEdit
class MyClass: pass
Hindi:
Python class pass keyword
6. Is it possible to call parent class without its instance
creation?
English:
Yes, using the super() function in child class.
Hindi:
,parent class super() object access
7. Are access specifiers used in Python?
English:
Yes, but not like Java/C++. Python uses naming conventions:
_protected
__private
public (default)
Hindi:
Python access specifiers ,syntax :
_ protected
__ private
public
8. How do you access parent members in the child
class?
English:
Use super() to call parent class methods or constructor.
python
CopyEdit
class A: def display(self): print("A") class B(A): def show(self): super().display()
Hindi:
Parent class members access super()
9. How does inheritance work in Python? Explain with
example.
English:
Inheritance lets a child class use properties/methods of the parent class.
python
CopyEdit
class Animal: def speak(self): print("Animal speaks") class Dog(Animal): def bark(self):
print("Dog barks") d = Dog() d.speak() # Inherited
Hindi:
Inheritance child class, parent class methods properties use
10. How do you create a class in Python?
English:
Use the class keyword.
python
CopyEdit
class Person: def __init__(self, name): self.name = name def greet(self): print(f"Hello,
{self.name}")
Hindi:
Python class keyword use class