Python Interview Questions for Freshers in India (2026): With Answers
Python is now the default language for data science, automation, and scripting roles — and increasingly for backend and full-stack positions too. At most Indian IT companies (TCS, Infosys, Wipro, Cognizant, HCL, Accenture), the technical round for fresher roles includes Python questions even when Python isn't the primary job requirement. This guide covers what actually gets asked, with answers you can use directly.
Core language fundamentals
These appear in almost every fresher screening, regardless of company or role.
1. What is the difference between a list and a tuple?
| | List | Tuple |
|-|------|-------|
| Mutability | Mutable (can change) | Immutable (cannot change) |
| Syntax | [1, 2, 3] | (1, 2, 3) |
| Use case | Collections that change | Fixed data (coordinates, DB rows) |
| Performance | Slightly slower | Slightly faster |
Follow-up you'll often get: "When would you prefer a tuple?" — Answer: when you want to ensure the data doesn't change accidentally, or when using it as a dictionary key (lists can't be dict keys; tuples can).
2. What are Python's built-in data types?
Numeric: int, float, complex
Sequence: list, tuple, range, str
Mapping: dict
Set: set, frozenset
Boolean: bool
Binary: bytes, bytearray
3. What is the difference between == and is?
== checks value equality. is checks identity — whether two variables point to the exact same object in memory.
a = [1, 2, 3]
b = [1, 2, 3]
print(a == b) # True — same values
print(a is b) # False — different objects
Common trap: small integers (-5 to 256) and short strings are cached in Python, so is can return True for them even when declared separately. Never rely on is for value comparison.
4. What is a decorator in Python?
A decorator is a function that wraps another function to add behaviour without modifying it.
def log(func):
def wrapper(*args, **kwargs):
print(f"Calling {func.__name__}")
return func(*args, **kwargs)
return wrapper
@log
def greet(name):
print(f"Hello, {name}")
greet("Arjun")
# Output:
# Calling greet
# Hello, Arjun
Decorators are used in frameworks (Flask @app.route, Django @login_required) and for cross-cutting concerns like logging, caching, and access control.
5. Explain list comprehensions with an example.
A list comprehension creates a new list from an iterable in one concise line.
# Traditional loop
squares = []
for x in range(1, 6):
squares.append(x ** 2)
# List comprehension
squares = [x ** 2 for x in range(1, 6)]
# [1, 4, 9, 16, 25]
With a condition:
evens = [x for x in range(10) if x % 2 == 0]
# [0, 2, 4, 6, 8]
OOP questions
6. What are the four pillars of OOP? Give Python examples.
- Encapsulation — bundling data and methods; use
_or__prefix to restrict access - Inheritance — a child class inherits from a parent class (
class Dog(Animal):) - Polymorphism — same method name, different behaviour across classes (method overriding)
- Abstraction — hiding implementation details; achieved with abstract base classes (
abcmodule)
7. What is the difference between __init__ and __new__?
__new__ creates the instance; __init__ initialises it. In normal code you only override __init__. You override __new__ for singletons or metaclasses — advanced patterns unlikely to come up in a fresher round, but worth knowing the distinction.
Common coding problems at Indian IT companies
These appear in the coding section of TCS NQT, Infosys Springboard tests, and walk-in drives.
8. Reverse a string without slicing
def reverse_string(s):
result = ""
for ch in s:
result = ch + result
return result
Interviewers sometimes ask you to do it without s[::-1] to test whether you understand iteration.
9. Check if a string is a palindrome
def is_palindrome(s):
s = s.lower().replace(" ", "")
return s == s[::-1]
10. Find duplicates in a list
def find_duplicates(lst):
seen = set()
duplicates = []
for item in lst:
if item in seen:
duplicates.append(item)
seen.add(item)
return list(set(duplicates))
11. Count the frequency of each character in a string
from collections import Counter
text = "interview"
freq = Counter(text)
print(freq) # Counter({'i': 2, 'n': 1, 't': 1, ...})
Python for data roles
If you're applying for data analyst, data engineer, or ML internship roles, expect these on top of the core questions.
12. What is the difference between a shallow copy and a deep copy?
- Shallow copy (
copy.copy()) — copies the outer object but references the same inner objects - Deep copy (
copy.deepcopy()) — recursively copies all nested objects
Matters when you have nested lists or objects and want the copy to be fully independent.
13. What are lambda functions?
Anonymous, single-expression functions, often used with map(), filter(), and sorted().
double = lambda x: x * 2
print(double(5)) # 10
# With sorted
names = ["Priya", "Arjun", "Zara"]
names.sort(key=lambda x: len(x))
# ['Zara', 'Priya', 'Arjun']
Tips for the Python technical round
Know your complexity. Interviewers at product companies (and some service companies) will ask why you chose a particular approach. A set lookup is O(1); a list search is O(n). Use in with a set, not a list, when you're checking membership repeatedly.
Write readable code. Name your variables clearly. An interviewer reading n, lst, tmp has to decode what you're doing; num_students, scores, max_score is self-documenting.
Talk while you code. In live technical rounds, narrate your thinking. "I'm using a dictionary here because I need O(1) lookups" shows you know why, not just what.
Practice on paper once. Campus drives sometimes have pen-and-paper rounds. Write out a function manually, including indentation — Python's whitespace rules become obvious failures on paper.
The Python questions most freshers miss aren't the hard ones — they're the "obvious" ones they never reviewed. Mutability,
isvs==, shallow vs deep copy. Spend 30 minutes on those before the interview and you'll be ahead of most candidates in the room.
If you want to see how your spoken technical explanations hold up under pressure, check out CareerClutch's mock interview sessions for Python and data-focused roles.