This blog contains the review of common interview questions and answers that are asked during a Data Science interview. You’ll get to know how to answer basic data science interview questions related to predictions, underfitting, and overfitting. Also, with 80 Data Science interview questions, you will walk through the typical questions related to statistics and probability and some more related to data structures and algorithms. The technical skills required to appear for the interview are: o Python o SQL o Statistics and Probability o Algorithms o Supervised and Unsupervised Machine Learning
Python is a high-level, interpreted,
and general-purpose programming language. General-purpose language means it can
be used to create almost any type of application with the right tools or
libraries. Python supports objects, modules, threads, exception-handling and
automatic memory management which helps in modeling real-world problems and
creating applications to solve these problems.
Typing means type-checking in
programming languages. Python is a strongly typed language which means
"1" + 2 will result in a type error, since these languages don't
allow for "type-coercion" (implicit conversion of data types). On the
other side, a weakly-typed language like
Type-checking can be done at two
Static - Data Types are checked
Dynamic - Data Types are checked
Python is known as an interpreted
language as it executes each statement line by line and thus type-checking is
done on the fly, during execution. By this means, Python is a Dynamically Typed
Namespaces in Python are known as
dictionaries with “name as key” mapped to a corresponding “object as value”.
This allows multiple namespaces to utilize the same name and map it to a
separate object. Following are the types of namespaces used in Python:
that includes local names inside a function. It is temporarily created for a
function call and gets cleared when the function returns.
that includes names from various imported packages or modules that are being
used in the current project. It is created when the package is imported in the
script and lasts until the execution of the script.
that includes built-in functions of core Python and built-in names for various
types of exceptions.
Local: It refers to the local
objects available in the current function.
Global: It refers to the objects
available throughout the code execution since their inception.
Module-level: It refers to the global
objects of the current module accessible in the program.
Outermost: It refers to all the
built-in names callable in the program. The objects in this scope are searched
last to find the name referenced.
Tip: Local scope objects can be
synced with global scope objects using keywords such as global.
Lists and Tuples are both sequence
data types that can store a collection of objects in Python. The objects stored
in both sequences can have different data types. Lists are represented with
square brackets ['John’, 6, 0.19], while tuples are represented with
parentheses ('Sena', 5, 0.97).
my_tuple = ('John', 6, 5,
my_list = ['John', 6, 5,
print(my_tuple) # output => 'John'
print(my_list) # output => 'John'
my_tuple = 'Sena' # modifying tuple => throws an error
print(my_tuple) # output => 'John'
print(my_list) # output => 'Sena'
For this, we use the method isalnum()
By using the method capitalize().
However, it will let other characters
Other methods that we have include:
>>> ' '.isspace()
With the use of a function named
getcwd(). It is used by importing it from the module OS.
>>> import os
Simply change the directly
we are currently using-
Firstly, create a list
Then use the method insert. The first
argument is the index at which to insert, the second is the value to insert
Using reverse() method
Or using a slicing method from right
>>> This sign is known as a
A function uses the ‘return’ keyword
to return a value.
>>> def add(a,b):
For any kind of statements, we
possibly need to define a block of code under them. However, Python does not support
curly braces. This means we must end such statements with colons and then
indent the blocks under those with the same amount.
>>> if 3>1:
Both break and continue statements
are the control flow statements in Python loops. Break statement stops the
current loop from executing further and transfers the control to the next
block. Continue statement jumps to the next iteration of the loop without
Python does not support an intrinsic
With the use of max() method
The output is ‘abcdefghij’. The first
slice gives us ‘abc’, the next gives us ‘defghij’.
By using join() method
By turning elements into a set
The Python dictionary holds key-value
pairs. It is mutable and uses a comprehension to create it.
With the operators ‘in’ and ‘not in’,
we can confirm if a value is a member in another.
>>> 'me' in 'disappointment'
>>> 'us' not in
The operators ‘is’ and ‘is not’ tell
us if two values have the same identity.
>>> 10 is '10'
>>> True is not False
If a string contains only numeric
characters, you can convert it into an integer using the int() function.
Do this to check the types:
When we want to execute a sequence of
statements, we can give it a name. Let’s define a function to take two numbers
and return the greater number.
return a is a>b else b
When a function makes a call to
itself, it is termed recursion. But then, in order for it to avoid forming an
infinite loop, we must have a base condition.
>>> def fact(n):
if n==1: return 1
To get all the keys from a
dictionary, keys() method is used.
>>> 'd' in
By using swapcase() method from the
>>> for i in s:
if i==' ': continue
>>> for i in
A Python program typically begins to
execute from the first line. From that point, it travels through every
statement only a single time and when it's finished with the last statement, it
exchanges the program. However, we might need to take an increasingly turned
path through the code. Control flow statements let us upset the ordinary
execution flow of a program and curve it to our will.
Pressing Ctrl+C key combination
interrupts the execution.
These let you modify their contents.
Examples of these are lists, sets, and dicts. Iterations on such objects are
These do not let us modify their
contents. Examples of these will be tuples, booleans, strings, integers,
floats, and complexes. Iterations on such objects are faster
Zip() function in Python returns a
zip object which maps a similar index of multiple containers.
zip(iterator1, iterator2, iterator3 ...)
string = " hello "
string2 = " hello
string3 = " hello"
stripping all have placed in a sequence:")
Decorators are very powerful and a
useful tool in Python that allows the programmers to modify the behavior of any
class or function. It allows us to wrap another function to extend the behavior
of the wrapped function, without permanently modifying it.
# Decorator example
The Python pickle is characterized as
a module which acknowledges any Python item and changes over it into a string
portrayal. It dumps the Python object into a record utilizing the landfill
work; this procedure is called pickling.
The way toward recovering the first
Python objects from the put away string representation is called Unpickling.
For loop and while loop
Module is defined as a file that
includes a set of various functions and Python statements that we want to add
in our application.
.py files are Python source files.
.pyc files are the compiled bytecode files that are generated by the Python
for a in range(r):
It is a Numerical Python that is used
to perform general and efficient calculations on numerical data that is saved
in arrays like indexing, reshaping, sorting, etc. It is majorly used to solve
linear algebraic functions.
It is a Scientific Python that is a
collection of tools that is used to perform various operations like
differentiation, integration, etc. It is majorly used to solve algebraic
If you want to add multiple comments,
you have to insert ‘#’ for each line.
#This is a comment
#more than just one line
This is a comment
more than just one line
Anonymous function is called a Lambda
function in Python. Lambda function has a number of parameters but has a single
a = lambda x,y : x+y
Docstrings are actually documentation
strings that are written within triple quotes. These are not assigned on any
variable and are used as general comments too.
Using docstring as a
This code divides 2
In Python, elements can be added
using various functions like append(), extend(), and insert(i,x)
a=arr.array('d', [1.1 ,
2.1 ,3.1] )
By using a class keyword
def __init__(self, name):
self.name = name
The term monkey patching refers to
the dynamic modifications of a class or a module during run-time.
m.MyClass.f = monkey_f
obj = m.MyClass()
When a class doesn’t have any code
within its block, is known as the empty class. To create an empty class, the pass keyword is used.
x = 10
There are thousands of vacancies
available for Python developers and Python experts are expected to be
acquainted with the components of Python technologies. With the knowledge of
how to use Python during interviews can help you understand the deepness of Python
programming that will pay dividends during day-to-day development. Python
knowledge is essential for the students and learners to get great employment
opportunities in the future. The knowledge of every small detail about Python
is the great approach to solve the problems linked with real-time scenarios. A
magical trick here is to read and re-read the questions and their answers to
get accustomed to what you will be asked in the Python interview. Let these
questions be your gateway to your next job as a Python expert.
Online / Classroom
Online / Classroom
Online / Classroom
Online / Classroom
Category: Data Analysis
"Got to know about Codegnan through google and joined in it after going through their reviews.It been a very encouraging and postivie experience right from getting details,joining and completing my microsoft certification exam.The staff here is very helpful in every possible way especially sai ram sir has been really good in helping through out the course.i highly recommend Codegnan."
"I have learned PYTHON course here.The teaching environment is very friendly here.they clear the doubts immediatly. I am very happy as i trained here and gained MTA badge.The best part is they focus on practical training.I suggest who are willing get train in python this is best place."