Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.
In this round, I was asked questions mainly from Python and OOPS.
What is Scope in Python?
Every object in Python functions within a scope. A scope is a block of code where an object in Python remains relevant. Namespaces uniquely identify all the objects inside a program. However, these namespaces also have a scope defined for them where you could use their objects without any prefix. A few examples of scope created during code execution in Python are as follows :
1) A local scope refers to the local objects available in the current function.
2) A global scope refers to the objects available throughout the code execution since their inception.
3) A module-level scope refers to the global objects of the current module accessible in the program.
4) An outermost scope refers to all the built-in names callable in the program. The objects in this scope are searched last to find the name referenced.
What is slicing in Python?
1) As the name suggests, ‘slicing’ is taking parts of.
2) Syntax for slicing is [start : stop : step]
3) start is the starting index from where to slice a list or tuple
4) stop is the ending index or where to sop.
5) step is the number of steps to jump.
6) Default value for start is 0, stop is number of items, step is 1.
7) Slicing can be done on strings, arrays, lists, and tuples.
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print(numbers[1 : : 2]) #output : [2, 4, 6, 8, 10]
How is memory managed in Python?
1) Memory management in Python is handled by the Python Memory Manager. The memory allocated by the manager is in form of a private heap space dedicated to Python. All Python objects are stored in this heap and being private, it is inaccessible to the programmer. Though, python does provide some core API functions to work upon the private heap space.
2) Additionally, Python has an in-built garbage collection to recycle the unused memory for the private heap space.
What are decorators in Python?
Decorators in Python are essentially functions that add functionality to an existing function in Python without changing the structure of the function itself. They are represented the @decorator_name in Python and are called in a bottom-up fashion. For example :
# decorator function to convert to lowercase
def lowercase_decorator(function):
def wrapper():
func = function()
string_lowercase = func.lower()
return string_lowercase
return wrapper
# decorator function to split words
def splitter_decorator(function):
def wrapper():
func = function()
string_split = func.split()
return string_split
return wrapper
@splitter_decorator # this is executed next
@lowercase_decorator # this is executed first
def hello():
return 'Hello World'
hello() # output => [ 'hello' , 'world' ]
The beauty of the decorators lies in the fact that besides adding functionality to the output of the method, they can even accept arguments for functions and can further modify those arguments before passing it to the function itself.
The inner nested function, i.e. 'wrapper' function, plays a significant role here.
It is implemented to enforce encapsulation and thus, keep itself hidden from the global scope.
What is pickling and unpickling?
Python library offers a feature - serialization out of the box. Serializing an object refers to transforming it into a format that can be stored, so as to be able to deserialize it, later on, to obtain the original object. Here, the pickle module comes into play.
Pickling :
1) Pickling is the name of the serialization process in Python. Any object in Python can be serialized into a byte stream and dumped as a file in the memory. The process of pickling is compact but pickle objects can be compressed further.
2) Moreover, pickle keeps track of the objects it has serialized and the serialization is portable across versions.
3) The function used for the above process is pickle.dump().
Unpickling :
1) Unpickling is the complete inverse of pickling. It deserializes the byte stream to recreate the objects stored in the file and loads the object to memory.
2) The function used for the above process is pickle.load().
What is the difference between .py and .pyc files?
1) .py files contain the source code of a program. Whereas, .pyc file contains the bytecode of your program. We get bytecode after compilation of .py file (source code). .pyc files are not created for all the files that you run. It is only created for the files that you import.
2) Before executing a python program python interpreter checks for the compiled files. If the file is present, the virtual machine executes it. If not found, it checks for .py file. If found, compiles it to .pyc file and then python virtual machine executes it.
3) Having .pyc file saves you the compilation time.
How Python is interpreted?
1)Python as a language is not interpreted or compiled. Interpreted or compiled is the property of the implementation.
Python is a bytecode(set of interpreter readable instructions) interpreted generally.
2) Source code is a file with .py extension.
3) Python compiles the source code to a set of instructions for a virtual machine. The Python interpreter is an implementation of that virtual machine. This intermediate format is called “bytecode”.
4) .py source code is first compiled to give .pyc which is bytecode. This bytecode can be then interpreted by the official CPython or JIT(Just in Time compiler) compiled by PyPy.
What is meant by Interface?
Multiple inheritances cannot be achieved in java. To overcome this problem the Interface concept is
introduced. An interface is a template which has only method declarations and not the method implementation.
Some imp. points about Interface :
1) All the methods in the interface are internally public abstract void.
2) All the variables in the interface are internally public static final that is constants.
3) Classes can implement the interface and not extends.
4) The class which implements the interface should provide an implementation for all the methods declared in the
interface.
Explain SOLID principles in Object Oriented Design .
The SOLID principle is an acronym of the five principles which is given below :
1) Single Responsibility Principle (SRP)
2) Open/Closed Principle
3) Liskov’s Substitution Principle (LSP)
4) Interface Segregation Principle (ISP)
5) Dependency Inversion Principle (DIP)
Uses of SOLID design principles :
1) The SOLID principle helps in reducing tight coupling.
2) Tight coupling means a group of classes are highly dependent on one another which we should avoid in our code.
3) Opposite of tight coupling is loose coupling and our code is considered as a good code when it has loosely-
coupled classes.
4) Loosely coupled classes minimize changes in your code, helps in making code more reusable, maintainable,
flexible and stable.
Explaining the 5 SOLID principles one by one :
1) Single Responsibility Principle : This principle states that “a class should have only one reason to change” which
means every class should have a single responsibility or single job or single purpose.
Use layers in your application and break God classes into smaller classes or modules.
2) Open/Closed Principle : This principle states that “software entities (classes, modules, functions, etc.) should be
open for extension, but closed for modification” which means you should be able to extend a class behavior, without
modifying it. Using this principle separates the existing code from the modified code so it provides better stability,
maintainability and minimizes changes as in your code.
3) Liskov’s Substitution Principle : According to this principle “Derived or child classes must be substitutable for their
base or parent classes“. This principle ensures that any class that is the child of a parent class should be usable in
place of its parent without any unexpected behavior.
4) Interface Segregation Principle : This principle is the first principle that applies to Interfaces instead of classes in
SOLID and it is similar to the single responsibility principle. It states that “do not force any client to implement an
interface which is irrelevant to them“. Here your main goal is to focus on avoiding fat interface and give preference to
many small client-specific interfaces.
5) Dependency Inversion Principle : Two key points are here to keep in mind about this principle
a) High-level modules/classes should not depend on low-level modules/classes. Both should depend upon
abstractions.
b) Abstractions should not depend upon details. Details should depend upon abstractions.
This round had questions from NumPy, Pandas and Design Patterns.
Define pandas dataframe.
A dataframe is a 2D mutable and tabular structure for representing data labelled with axes - rows and columns.
The syntax for creating dataframe :
import pandas as pd
dataframe = pd.DataFrame( data, index, columns, dtype)
where:
data - Represents various forms like series, map, ndarray, lists, dict etc.
index - Optional argument that represents an index to row labels.
columns - Optional argument for column labels.
Dtype - the data type of each column. Again optional.
How will you combine different pandas dataframes?
The dataframes can be combines using the below approaches :
append() method: This is used to stack the dataframes horizontally. Syntax :
df1.append(df2)
concat() method: This is used to stack dataframes vertically. This is best used when the dataframes have the same columns and similar fields. Syntax :
pd.concat([df1, df2])
join() method: This is used for extracting data from various dataframes having one or more common columns. Synatx :
df1.join(df2)
What do you understand by reindexing in pandas?
Reindexing is the process of conforming a dataframe to a new index with optional filling logic. If the values are missing in the previous index, then NaN/NA is placed in the location. A new object is returned unless a new index is produced that is equivalent to the current one. The copy value is set to False. This is also used for changing the index of rows and columns in the dataframe.
How are NumPy arrays advantageous over python lists?
1) The list data structure of python is very highly efficient and is capable of performing various functions.
2) But, they have severe limitations when it comes to the computation of vectorized operations which deals with element-wise multiplication and addition.
3) The python lists also require the information regarding the type of every element which results in overhead as type dispatching code gets executes every time any operation is performed on any element.
4) This is where the NumPy arrays come into the picture as all the limitations of python lists are handled in NumPy arrays.
5) Additionally, as the size of the NumPy arrays increases, NumPy becomes around 30x times faster than the Python List. This is because the Numpy arrays are densely packed in the memory due to their homogenous nature. This ensures the memory free up is also faster.
How will you find the nearest value in a given numpy array?
We can use the argmin() method of numpy as shown below :
import numpy as np
def find_nearest_value(arr, value):
arr = np.asarray(arr)
idx = (np.abs(arr - value)).argmin()
return arr[idx]
#Driver code
arr = np.array([ 0.21169, 0.61391, 0.6341, 0.0131, 0.16541, 0.5645, 0.5742])
value = 0.52
print(find_nearest_value(arr, value)) # Prints 0.5645
Differentiate between a package and a module in python.
1) The module is a single python file. A module can import other modules (other python files) as objects. Whereas, a package is the folder/directory where different sub-packages and the modules reside.
2) A python module is created by saving a file with the extension of .py. This file will have classes and functions that are reusable in the code as well as across modules.
A python package is created by following the below steps :
1) Create a directory and give a valid name that represents its operation.
2) Place modules of one kind in this directory.
3) Create __init__.py file in this directory. This lets python know the directory we created is a package. The contents of this package can be imported across different modules in other packages to reuse the functionality.
What is Factory pattern?
Factory pattern is one of most used design pattern and comes under creational patterns category.
In Factory pattern, we create object without exposing the creation logic to the client and refer to newly created object using a common interface.
Pro's :
1) Allows you to hide implementation of an application seam (the core interfaces that make up your application)
2) Allows you to easily test the seam of an application (that is to mock/stub) certain parts of your application so you can build and test the other parts
3) Allows you to change the design of your application more readily, this is known as loose coupling
Con's :
1) Makes code more difficult to read as all of your code is behind an abstraction that may in turn hide abstractions.
2) Can be classed as an anti-pattern when it is incorrectly used, for example some people use it to wire up a whole application when using an IOC container, instead use Dependency Injection.
What are the difference between a Static class and a Singleton class?
Following are the differences between a static class and a singleton class.
1) A static class can not be a top level class and can not implement interfaces where a singleton class can.
2) All members of a static class are static but for a Singleton class it is not a requirement.
3) A static class get initialized when it is loaded so it can not be lazily loaded where a singleton class can be lazily loaded.
4) A static class object is stored in stack whereas singlton class object is stored in heap memory space.
What is Dependency Injection?
Dependency injection makes it easy to create loosely coupled components, which typically means that components consume functionality defined by interfaces without having any first-hand knowledge of which implementation classes are being used.
Dependency injection makes it easier to change the behavior of an application by changing the components that implement the interfaces that define application features. It also results in components that are easier to isolate for unit testing.
This was a Technical Cum HR round where I was first asked some questions revolving around my projects and then we discussed about my expectations from the company , learnings and growth in the forthcomig years. I would suggest be honest and try to communicate your thoughts properly in these type of rounds to maximise your chances of getting selected.
Why should we hire you ?
What are your expectations from the company?
How was your overall interview experience?
What are your strengths and weakness according to you?
Where do you see yourself in the next 5 years?
Tip 1 : The cross questioning can go intense some time, think before you speak.
Tip 2 : Be open minded and answer whatever you are thinking, in these rounds I feel it is important to have opinion.
Tip 3 : Context of questions can be switched, pay attention to the details. It is okay to ask questions in these round,
like what are the projects currently the company is investing, which team you are mentoring. How all is the work
environment etc.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is recursion?