If you’re a fresher applying to TCS, Infosys, or Wipro, there’s a good chance Python now shows up somewhere in your interview process — in the coding round, the technical round, or both. These three companies hire some of the largest fresher batches in India every year, and Python has become a standard part of their entry-level tech and digital tracks.
This list of python interview questions for freshers is built around the patterns we see most often at Fast Learning Technologies, where we train and place candidates into exactly these kinds of roles. It’s organized by topic so you can study in order, then jump straight to the company-specific section once the fundamentals feel solid.
Read each answer once for understanding, then come back and try to answer the question cold — that second pass is what actually sticks before an interview.

Basic Python Interview Questions for Freshers (Q1-15)
These cover the fundamentals every interviewer expects you to know without hesitation.
Q1. What is Python, and why do companies like TCS, Infosys, and Wipro use it for fresher hiring? Python is a high-level, general-purpose, interpreted programming language known for readable syntax and a huge standard library. Service companies favor it for fresher roles because it’s quick to teach, used across automation, data, and backend projects, and lets new hires become productive faster than with lower-level languages.
Q2. What are the key features of Python? Python is interpreted, dynamically typed, and supports multiple programming paradigms (procedural, object-oriented, and functional). It has automatic memory management, an extensive standard library, and a large ecosystem of third-party packages available through pip.
Q3. What is the difference between Python 2 and Python 3? Python 3 changed print from a statement to a function, made integer division (/) return a float by default, and switched strings to Unicode by default. Python 2 reached end-of-life in 2020, so all current interview prep and production code should target Python 3.
Q4. What are Python’s built-in data types? The core types are numeric (int, float, complex), sequence types (str, list, tuple), mapping type (dict), set types (set, frozenset), and boolean (bool). Interviewers often ask you to classify these as mutable or immutable as a quick follow-up.
Q5. What is the difference between list, tuple, set, and dictionary?
- List — ordered, mutable, allows duplicates:
[1, 2, 2, 3] - Tuple — ordered, immutable, allows duplicates:
(1, 2, 3) - Set — unordered, mutable, no duplicates:
{1, 2, 3} - Dictionary — unordered key-value pairs, mutable, unique keys:
{"a": 1, "b": 2}
Q6. What is the difference between mutable and immutable objects? Give examples. A mutable object can be changed after creation (lists, dictionaries, sets), while an immutable object cannot (integers, strings, tuples, frozensets). This matters in interviews because passing mutable objects into functions can lead to unexpected side effects if you’re not careful.
Q7. What is the difference between is and ==? == checks whether two objects have the same value, while is checks whether they’re the same object in memory. Two equal lists can return True for == but False for is, since they’re separate objects with the same contents.
Q8. What are *args and **kwargs? *args lets a function accept any number of positional arguments, collected into a tuple. **kwargs lets a function accept any number of keyword arguments, collected into a dictionary. Both are common in interview questions about flexible function signatures.
Q9. What is a lambda function? Give an example. A lambda is a small, anonymous function defined in a single line using the lambda keyword, typically for short operations passed into functions like map() or filter().
python
square = lambda x: x * x
print(square(5)) # 25
Q10. What is list comprehension? Write an example. List comprehension is a concise way to build a list from an iterable in a single line, often replacing a multi-line for loop.
python
squares = [x**2 for x in range(10) if x % 2 == 0]
Q11. What is the difference between deep copy and shallow copy? A shallow copy (copy.copy()) creates a new outer object but keeps references to the same nested objects. A deep copy (copy.deepcopy()) recursively copies every nested object, so changes to the copy never affect the original.
Q12. What is the difference between local and global variables? A local variable is defined inside a function and only accessible within it. A global variable is defined at the module level and accessible everywhere, though you need the global keyword to modify it from inside a function.
Q13. What does the range() function do? range() generates a sequence of numbers, commonly used in loops. In Python 3, range() returns a memory-efficient range object rather than a full list (the separate xrange() from Python 2 no longer exists, since range() now behaves that way by default).
Q14. What is PEP 8? PEP 8 is Python’s official style guide, covering naming conventions, indentation, line length, and formatting. Interviewers sometimes ask this to gauge whether you write clean, readable code, not just working code.
Q15. What is the difference between append() and extend() in a list? append() adds a single item to the end of a list, even if that item is itself a list. extend() adds each element of an iterable individually.
python
a = [1, 2]
a.append([3, 4]) # [1, 2, [3, 4]]
b = [1, 2]
b.extend([3, 4]) # [1, 2, 3, 4]
Python OOP Interview Questions (Q16-25)
Object-oriented programming questions are almost guaranteed in Infosys and Wipro technical rounds, since both companies build heavily on Java/Python OOP foundations.
Q16. What is Object-Oriented Programming, and what are Python’s four OOP pillars? OOP is a programming style organized around objects that bundle data and behavior together. Python’s four pillars are encapsulation, inheritance, polymorphism, and abstraction.
Q17. What is a class and an object in Python? A class is a blueprint that defines attributes and methods. An object is a specific instance of that class, created in memory with its own data.
python
class Car:
pass
my_car = Car() # my_car is an object of class Car
Q18. What is self used for in Python classes? self refers to the current instance of the class and must be the first parameter of any instance method. It’s how a method accesses and modifies the specific object’s attributes.
Q19. What is the __init__() method? __init__() is Python’s constructor method, automatically called when a new object is created, typically used to initialize instance attributes.
python
class Student:
def __init__(self, name, marks):
self.name = name
self.marks = marks
Q20. What is inheritance? Explain with an example. Inheritance lets a class (child/subclass) acquire attributes and methods from another class (parent/superclass), promoting code reuse.
python
class Animal:
def speak(self):
print("Animal sound")
class Dog(Animal):
def speak(self):
print("Bark")
Q21. What is the difference between method overriding and method overloading in Python? Overriding happens when a subclass redefines a method already present in its parent class with the same name and signature. Python doesn’t support traditional method overloading (same name, different parameter lists) — that effect is typically achieved with default arguments or *args.
Q22. What is encapsulation, and how is it implemented in Python? Encapsulation means bundling data and the methods that operate on it inside a class, restricting direct access to internal details. Python uses naming conventions for this — a single underscore (_var) signals “protected” by convention, and a double underscore (__var) triggers name mangling to make an attribute harder to access from outside the class.
Q23. What is polymorphism? Give a simple example. Polymorphism means the same method name or operator behaves differently depending on the object it’s called on.
python
class Cat:
def sound(self):
return "Meow"
class Cow:
def sound(self):
return "Moo"
for animal in [Cat(), Cow()]:
print(animal.sound())
Q24. What is the difference between class variables and instance variables? A class variable is shared across all instances of a class and defined directly inside the class body. An instance variable is unique to each object and typically defined inside __init__() using self.
Q25. What are dunder (magic) methods? Give two examples. Dunder methods are special methods surrounded by double underscores that let objects integrate with Python’s built-in syntax. __init__() initializes an object, and __str__() controls what’s returned when you print() an object.
Python Data Structures & String Handling Questions (Q26-35)
These questions test how comfortable you are actually manipulating data — a strong predictor of how you’ll perform in a live coding round.
Q26. How does slicing work in Python? Give examples. Slicing extracts a portion of a sequence using sequence[start:stop:step], where stop is exclusive.
python
s = "Bangalore"
print(s[0:4]) # Bang
print(s[::-1]) # eroagnaB
Q27. What is the difference between .find() and .index() for strings? Both search for a substring, but .find() returns -1 if it’s not found, while .index() raises a ValueError. Use .find() when a missing match is expected and shouldn’t crash your program.
Q28. How do you reverse a string in Python? The most common one-liner uses extended slicing: reversed_str = original_str[::-1].
Q29. What is the difference between sort() and sorted()? sort() sorts a list in place and returns None. sorted() returns a new sorted list and works on any iterable, leaving the original unchanged — interviewers often ask this to catch candidates who forget sort() doesn’t return anything usable.
Q30. How do you remove duplicates from a list? The quickest way is list(set(my_list)), though it doesn’t preserve order. To keep the original order, use list(dict.fromkeys(my_list)).
Q31. What are Python sets, and when would you use one over a list? A set is an unordered collection of unique, hashable elements. Use a set when you need fast membership checks or need to eliminate duplicates, since lookups average O(1) compared to O(n) for a list.
Q32. How do dictionaries work internally in Python? Dictionaries are implemented as hash tables. Each key is passed through a hash function to determine where its value is stored, which is why key lookups are close to O(1) on average regardless of dictionary size.
Q33. What is the difference between .pop(), .remove(), and del?
.pop(index)removes and returns the item at a given index (or the last item by default).remove(value)removes the first matching value, returns nothingdel list[index]deletes by index or slice, returns nothing
Q34. How do you check if a string is a palindrome in Python? Compare the string to its reverse:
python
def is_palindrome(s):
return s == s[::-1]
Q35. What are the different ways to format strings in Python? Python supports the older % operator, the .format() method, and f-strings (available from Python 3.6+). F-strings are generally preferred for readability and performance: f"Hello, {name}!".
Python Exception Handling, File Handling & Modules (Q36-43)
Q36. What is exception handling, and how does try/except/else/finally work? Exception handling lets a program respond to runtime errors instead of crashing. The try block contains risky code, except catches specific errors, else runs only if no exception occurred, and finally always runs regardless of what happened.
Q37. How do you create a custom exception in Python? Define a new class that inherits from Exception:
python
class InsufficientMarksError(Exception):
pass
raise InsufficientMarksError("Marks below passing threshold")
Q38. What is the difference between Exception and BaseException? BaseException is the root class for all exceptions, including system-level events like SystemExit and KeyboardInterrupt. Exception is a subclass of BaseException covering standard errors, and it’s the one you should generally catch — catching BaseException directly can accidentally swallow program-exit signals.
Q39. How do you read and write files in Python? Use the built-in open() function with the appropriate mode ('r' read, 'w' write, 'a' append), ideally inside a with block:
python
with open("data.txt", "r") as f:
content = f.read()
Q40. What is the difference between import module and from module import function? import module brings in the whole module, and you access its contents with module.function(). from module import function brings a specific function directly into your namespace, so you can call it as function() without the prefix.
Q41. What is the difference between a Python module and a package? A module is a single .py file containing functions, classes, or variables. A package is a directory containing multiple modules, marked by an __init__.py file (optional from Python 3.3 onward, but still common practice).
Q42. What is pip, and how do you use it to install packages? Pip is Python’s standard package manager, used to install third-party libraries from the Python Package Index (PyPI) with a command like pip install requests.
Q43. Why is with open() preferred over manually calling open() and close()? with open() uses a context manager that automatically closes the file once the block finishes — even if an exception occurs inside it. Manual open()/close() calls risk leaving the file open if an error happens before close() is reached.
Company-Specific Focus: What TCS, Infosys & Wipro Actually Ask (Q44-50)
Beyond core concepts, each company has a slightly different flavor of question. Knowing the pattern helps you prepare smarter, not just harder.
TCS Python Interview Questions: Output-Prediction & Logic
TCS’s NQT and Ninja-level rounds lean heavily on “predict the output” questions designed to test whether you actually understand Python’s behavior, not just syntax.
Q44. Predict the output:
python
def add_item(item, lst=[]):
lst.append(item)
return lst
print(add_item(1))
print(add_item(2))
This prints [1] then [1, 2] — not [2] as many candidates expect. Default mutable arguments are created once, when the function is defined, and reused across every call. It’s one of the most common TCS-style “gotcha” questions.
Q45. Predict the output:
python
x = 5
def foo():
print(x)
x = 10
foo()
This raises an UnboundLocalError. Because x is assigned somewhere inside foo(), Python treats it as a local variable for the entire function — so the print(x) line fails before the assignment ever runs.
Q46. Write a function to check if a number is prime.
python
def is_prime(n):
if n < 2:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
TCS interviewers often follow up by asking you to optimize the loop range, which is why checking only up to the square root matters.
Infosys Python Interview Questions: OOP & Basic DSA
Infosys interviews (including InfyTQ-style assessments) tend to combine OOP design with simple data structure problems.
Q47. Design a simple class hierarchy for a Vehicle and a Car.
python
class Vehicle:
def __init__(self, brand):
self.brand = brand
def describe(self):
return f"{self.brand} vehicle"
class Car(Vehicle):
def __init__(self, brand, model):
super().__init__(brand)
self.model = model
def describe(self):
return f"{self.brand} {self.model}"
This tests whether you can use super() correctly and understand how method overriding fits into a class hierarchy.
Q48. Find the second-largest number in a list without using sort() or max().
python
def second_largest(nums):
largest = second = float('-inf')
for n in nums:
if n > largest:
largest, second = n, largest
elif largest > n > second:
second = n
return second
This is a classic basic-DSA question used to check whether you can solve a problem in a single pass instead of relying on built-in shortcuts.
Wipro Python Interview Questions: Debugging & Conceptual Clarity
Wipro’s rounds (including WILP/Elite-style interviews) often hand you broken code and ask you to fix it, alongside conceptual “why” questions.
Q49. Find and fix the bug:
python
def calculate_average(numbers):
total = 0
for i in range(1, len(numbers)):
total += numbers[i]
return total / len(numbers)
The loop starts at index 1 instead of 0, so it skips the first element of the list. The fix is range(0, len(numbers)) or simply range(len(numbers)).
Q50. Is Python a compiled or an interpreted language? Python is generally described as interpreted, but it’s more precise to say your source code is first compiled into bytecode (.pyc files), which the Python Virtual Machine then interprets line by line at runtime. This nuance is a favorite Wipro conceptual question because it separates candidates who memorized “Python is interpreted” from those who actually understand the execution model.
How to Prepare for Python Interviews at TCS, Infosys & Wipro
Knowing the answers above gets you most of the way there, but how you practice matters just as much.
- Type the code yourself. Reading an answer and typing it from scratch in an IDE are completely different skills — interviewers can tell the difference immediately.
- Practice explaining out loud. Most fresher rounds are verbal-first; being able to explain
isvs==in plain English matters as much as knowing the definition. - Time yourself on output-prediction questions. TCS-style rounds are often timed, so practice reading code quickly under light pressure rather than only solving problems at your own pace.
- Do at least one mock interview. A second person catching where you hesitate is far more useful than another hour of silent revision.
- Revisit the company-specific section the night before. Refreshing the TCS, Infosys, and Wipro patterns right before your interview keeps them top of mind when it counts.
Final Thoughts
These 50 python interview questions for freshers cover what TCS, Infosys, and Wipro consistently test — fundamentals, OOP, data structures, and each company’s specific style of question. The candidates who do best aren’t the ones who memorized every answer; they’re the ones who practiced explaining these concepts clearly under a bit of pressure.
If you’d like structured practice, mock interviews, and a placement-focused Python track built around exactly these patterns, contact Fast Learning Technologies in Bangalore for current batch details — our trainers work with these question patterns every single batch.