Thursday, August 7, 2025

Nitheen Kumar

Capgemini Python Technical Interview Questions Answers

 

Capgemini Python Technical Interview Questions and Answers

Python has become one of the most popular programming languages because of its simplicity, versatility, and wide range of applications. At Capgemini, Python is used in automation, data analysis, machine learning, web development, and cloud solutions. If you are preparing for a Capgemini Python technical interview, expect both conceptual questions and hands-on coding problems.

Below, I’ve compiled the most commonly asked Python interview questions with answers, ranging from beginner to advanced levels.

1. Basic Python Interview Questions

Q1. What are the key features of Python?

  • Interpreted and dynamically typed

  • High readability with simple syntax

  • Large standard library

  • Supports OOP, functional, and procedural programming

  • Platform-independent

Q2. What is PEP 8 in Python?
PEP 8 is the official style guide for Python code, which defines best practices for writing clean and readable code.

Q3. What are Python’s data types?

  • Numeric (int, float, complex)

  • Sequence (list, tuple, range)

  • Text (str)

  • Set (set, frozenset)

  • Mapping (dict)

  • Boolean (bool)

  • Binary (bytes, bytearray)

Q4. How do lists and tuples differ in Python?

  • List: Mutable, allows modification. Example: mylist = [1,2,3]

  • Tuple: Immutable, faster, used for fixed data. Example: mytuple = (1,2,3)

Q5. How is memory managed in Python?

  • Automatic garbage collection via reference counting and generational GC.

  • Objects with zero references are automatically destroyed.


2. Intermediate Python Interview Questions

Q6. What are Python decorators?
A decorator is a function that modifies the behavior of another function without changing its source code. Example:

def decorator(func):
    def wrapper():
        print("Before execution")
        func()
        print("After execution")
    return wrapper

@decorator
def hello():
    print("Hello World")

hello()

Q7. What is the difference between is and == in Python?

  • is → checks for identity (whether two objects are the same in memory).

  • == → checks for equality (whether values are equal).

Q8. How does Python handle exceptions?
Using try-except blocks:

try:
    x = 10 / 0
except ZeroDivisionError as e:
    print("Error:", e)
finally:
    print("Cleanup actions")

Q9. What are Python’s built-in data structures?

  • List → dynamic array

  • Tuple → immutable ordered collection

  • Set → unordered collection of unique elements

  • Dict → key-value pairs

Q10. What is the Global Interpreter Lock (GIL) in Python?

  • GIL ensures that only one thread executes Python bytecode at a time.

  • Useful for memory management, but it limits true parallel execution in multi-threading.

  • Multiprocessing can be used to bypass GIL restrictions.


3. Advanced Python Interview Questions

Q11. Explain Python’s memory model and garbage collection.

  • Memory is managed with private heap space.

  • Objects are reference-counted.

  • Cyclic references are cleared by Python’s generational garbage collector.

Q12. How do you manage virtual environments in Python?

  • Using venv or virtualenv:

python -m venv myenv
source myenv/bin/activate  # Linux/macOS
myenv\Scripts\activate     # Windows

Q13. What are Python metaclasses?

  • Metaclasses define the behavior of classes.

  • By default, type is the metaclass for all classes.

  • Custom metaclasses can be created to control class creation.

Q14. How do you achieve multithreading and multiprocessing in Python?

  • Multithreading: Using threading module (limited by GIL).

  • Multiprocessing: Using multiprocessing module for true parallelism.

Q15. How does Python handle memory leaks?

  • Garbage collector manages most cases.

  • Memory leaks may occur due to circular references or global variables.

  • Tools like gc module and objgraph help detect leaks.


4. Real-Time Coding Questions Asked at Capgemini

Q16. Write a Python program to check if a string is a palindrome.

s = "madam"
print(s == s[::-1])  # True

Q17. How do you remove duplicates from a list in Python?

mylist = [1,2,2,3,4,4,5]
unique = list(set(mylist))
print(unique)

Q18. Write a Python program to count the frequency of characters in a string.

from collections import Counter
s = "capgemini"
print(Counter(s))

Q19. Write a Python function to find the factorial of a number using recursion.

def factorial(n):
    return 1 if n == 0 else n * factorial(n-1)

print(factorial(5))  # 120

Q20. How do you connect Python to a database?
Using SQLite:

import sqlite3
conn = sqlite3.connect('test.db')
cursor = conn.cursor()
cursor.execute("CREATE TABLE IF NOT EXISTS users(id INTEGER, name TEXT)")
cursor.execute("INSERT INTO users VALUES(1, 'Alice')")
conn.commit()
conn.close()

5. Scenario-Based Python Questions

  • How would you parse a JSON API response in Python?

  • How would you optimize a slow-running Python script?

  • How would you implement caching in Python?

  • How do you handle huge CSV file processing in Python?


Final Thoughts

In Capgemini Python interviews, you should be prepared for:

  • Core Python concepts: data structures, functions, OOP, decorators, exceptions.

  • Practical coding: working with strings, lists, files, and APIs.

  • Advanced topics: GIL, multiprocessing, decorators, memory management.

  • Scenario-based tasks: automation scripts, data parsing, performance tuning.

If you have a solid grasp of fundamentals along with hands-on coding practice, you’ll be confident enough to clear Capgemini’s Python technical rounds.

Subscribe to get more Posts :