Python
Python
Benefits:
Easy to learn: Python has a simple and straightforward
syntax, making it easy to learn and write code, even for
those who are new to programming.
01 | Heemali Chaudhari
What is a dynamically typed language?
A dynamically typed language is a programming language
where the type of a variable is determined at runtime,
rather than at compile time. This means that the type of a
variable can change during the execution of a program,
and that variables can be assigned values of different types
during their lifetime.
02 | Heemali Chaudhari
What is PEP 8 and why is it important?
PEP 8 is the style guide for writing Python code. It was
created to ensure that Python code is written in a consistent
and readable manner. It provides guidelines for naming
conventions, indentation, line lengths, and other aspects of
coding style.
03 | Heemali Chaudhari
What are lists and tuples? What is the key difference
between the two?
The key difference between lists and tuples is that lists are
mutable and tuples are immutable. This means that lists
can be changed, while tuples cannot. Because tuples are
immutable, they are often used to store values that are
constant and should not be changed, such as a collection of
data that represents a point in space, a date, or a color.
04 | Heemali Chaudhari
What is pass in Python?
In Python, the "pass" statement is a placeholder statement
that does nothing. It is used in situations where a
statement is required syntactically, but no action needs to
be performed. For example, when you define an empty
class, you can use the "pass" statement to prevent the
interpreter from raising an error.
05 | Heemali Chaudhari
What are modules and packages in Python?
In Python, modules and packages are ways to organize and
structure your code into reusable and manageable units.
06 | Heemali Chaudhari
What are global, protected and private attributes in
Python?
Global Attributes: Attributes that are declared outside of
any class or function are considered to be global
attributes. They are accessible from anywhere in the code,
and can be modified from any scope. Global attributes are
usually denoted by capital letters, for example:
GLOBAL_VARIABLE.
07 | Heemali Chaudhari
What is the use of self in Python?
08 | Heemali Chaudhari
What is break, continue and pass in Python?
break, continue, and pass are keywords in Python that are
used to control the flow of a loop. Here's a brief
explanation of each:
09 | Heemali Chaudhari
What is slicing in Python?
Slicing in Python is a way to get a part of a list, a string, or
an array by specifying the start and end points. It's like
cutting a piece of a long rope, or a portion of a big pizza.
You can tell Python exactly where you want to start
cutting, and where you want to stop. Slicing is a useful way
to extract parts of a large data structure and work with
smaller, more manageable pieces.
11 | Heemali Chaudhari
What is Scope Resolution in Python?
Scope resolution in Python refers to the process of determining
the namespace in which a variable or object is defined. Python
uses a scope hierarchy to determine the scope of an identifier
(variable, function, class, etc.).
There are two main types of scopes in Python: global scope and
local scope.
12 | Heemali Chaudhari
What is pickling and unpickling?
In Python, pickling and unpickling are the processes of
converting a Python object hierarchy into a byte stream,
and vice versa. The term "pickling" comes from the word
"pickle," which means to preserve food by storing it in a
jar with vinegar.
13 | Heemali Chaudhari
What are generators in Python?
Generators are a special type of iterator in Python, used to
generate a sequence of values one at a time, instead of
generating all the values at once in a data structure like a list
or a tuple. The main advantage of using generators is
memory efficiency, as the values are generated one at a time
as they are needed, instead of being stored in memory all at
once.
14 | Heemali Chaudhari
Explain split() and join() functions in Python?
The split() and join() functions are string methods in
Python used to manipulate strings.
15 | Heemali Chaudhari
How do you access parent members in the child class?
In Python, you can access parent class members in the
child class using the super() function. The super() function
returns a temporary object of the parent class, allowing
you to call its methods.
16 | Heemali Chaudhari
What is init method in python?
"init" is a special method in Python classes, also known as
a constructor. It is automatically called when an object of
the class is created, and it is used to initialize the attributes
of the class.
17 | Heemali Chaudhari
What are python modules?
In Python, a module is a file that contains definitions and
statements. A module can define functions, classes, and
variables, and it can also contain executable statements.
Modules can be imported into other modules or into the main
module (the module that is executed when you run a script).
19 | Heemali Chaudhari
What are docstrings in Python?
In Python, docstrings are strings that provide documentation for
a module, function, class, or method. They are placed at the
beginning of the code block, inside triple quotes (either single or
double quotes), and serve as the first line of documentation for
the code.
20 | Heemali Chaudhari
What does len() do?
The len() function in Python returns the number of
elements in a sequence (such as a string, list, tuple, etc.).
21 | Heemali Chaudhari
Does Python have OOps concepts?
Yes, Python supports Object-Oriented Programming (OOP)
concepts such as classes, objects, inheritance, polymorphism,
and encapsulation.
22 | Heemali Chaudhari
What is split used for?
In Python, the split() method is used to split a string into a
list of substrings based on a specified separator. The
separator can be any character, and by default, it is
whitespace. The resulting substrings are stored in a list,
and the list is returned as the output.
23 | Heemali Chaudhari
Why use OOPs?
OOP is a popular programming approach because it offers
several benefits for software development. Firstly, OOP
provides a way to organize code into reusable and modular
components, which makes it easier to maintain and extend
the code over time. Additionally, OOP enables developers
to model real-world objects and their relationships,
making it easier to understand and work with complex
systems.
24 | Heemali Chaudhari
What are the main features of OOPs?
The main features of Object-Oriented Programming (OOP) are:
25 | Heemali Chaudhari
Explain Inheritance in Python with an example.
Inheritance is a key concept in Object-Oriented
Programming that allows you to create a new class based on
an existing class, inheriting all its properties and behaviors.
This makes it possible to reuse and extend existing code,
reducing duplicated code and making it easier to maintain
the code over time.
26 | Heemali Chaudhari
What is Polymorphism in Python?
Polymorphism is a key concept in Object-Oriented
Programming that allows objects of different classes to be
treated as objects of a common type. This makes it possible
to write code that can work with objects of different types
in a generic way, without having to know the specific type
of the object at runtime.
27 | Heemali Chaudhari
Differentiate between overloading and overriding.
Method overloading is a feature of object-oriented
programming that allows a class to have multiple methods
with the same name but different parameters. This allows
the class to perform different actions based on the
arguments passed to the method. For example, a class
might have two methods with the same name but one takes
an integer argument and the other takes a string
argument. When the method is called, the correct
implementation will be selected based on the type of
argument passed to it.
28 | Heemali Chaudhari
What are ‘access specifiers’?
Access specifiers are keywords in object-oriented
programming (OOP) that define the level of access to the
members (attributes and methods) of a class. The access level
of a member determines who can access and modify it within
the program.
29 | Heemali Chaudhari
What is the difference between multiple and multilevel
inheritance?
Multiple inheritance is when a class inherits attributes and
methods from multiple parent classes. It allows a class to
inherit the characteristics of more than one parent class.
For example, if a class Child inherits from two classes
Parent1 and Parent2, it will have access to the attributes
and methods of both Parent1 and Parent2.
30 | Heemali Chaudhari
What are the limitations of inheritance?
Inheritance is a powerful feature in object-oriented
programming (OOP) that allows classes to inherit
attributes and methods from parent classes. However,
it also has some limitations:
Complexity: Inheritance can increase the complexity
of the code, making it harder to understand and
maintain. When classes inherit from multiple parent
classes, the relationships between classes can become
difficult to understand, especially when inheritance
hierarchies become deep and complex.
Overuse: Inheritance should be used carefully and
only when it is the most appropriate solution. Overuse
of inheritance can lead to complex, inflexible, and
hard-to-maintain code.
31 | Heemali Chaudhari
What are virtual functions?
In Python, virtual functions or "duck typing" is a feature of
the dynamic typing system that allows a method or function
to be called on objects of different types, as long as they
implement the required method or interface. This is done
based on the type of the object at runtime rather than the
type declared in the code.
32 | Heemali Chaudhari
What is a destructor?
In Python, a destructor is a special method that is
automatically called when an object is about to be
destroyed. The purpose of a destructor is to perform any
necessary clean-up operations, such as freeing resources or
closing files, before the object is destroyed.
What is an exception?
An exception in Python is an event that occurs during the
execution of a program that disrupts the normal flow of
the program's instructions. Exceptions are raised when a
runtime error occurs, such as dividing by zero or trying to
access an index that is out of range. When an exception is
raised, the normal flow of the program is interrupted and
the program execution is transferred to the nearest
exception handling code.
33 | Heemali Chaudhari
What is a map function in Python?
The map function in Python is a built-in function that
applies a function to each item of an iterable (such as a list,
tuple, or string) and returns a map object with the results.
The map object can be converted to other Python objects
(such as a list) using the list or tuple constructor.
34 | Heemali Chaudhari
Is Python fully object oriented?
Yes, Python is considered a fully object-oriented
programming language. This means that almost
everything in Python is an object, including numbers,
strings, functions, and even modules.
35 | Heemali Chaudhari
What is functional programming? Does Python follow a
functional programming style?
Functional programming is a programming paradigm that
emphasizes the use of pure functions, immutability, and
the avoidance of side effects. In functional programming,
functions are first-class citizens and are treated as building
blocks that can be combined to create complex programs.
36 | Heemali Chaudhari
What is the difference between / and // operator in Python?
In Python, the / operator performs floating-point division,
while the // operator performs integer division, also known as
floor division.
What is pandas?
Pandas is an open-source data analysis and data
manipulation library for Python. It provides data structures
for efficiently storing large amounts of structured data, as
well as tools for working with that data in a convenient and
expressive way.
37 | Heemali Chaudhari
How do you identify missing values and deal with missing values
in Dataframe?
Identifying missing values in a pandas DataFrame can be done
using the isna() or isnull() methods, which return a DataFrame
of the same shape as the original DataFrame with True values in
cells where missing (null) values are detected.
What is regression?
Regression is a statistical method for modeling the relationship
between a dependent variable and one or more independent
variables. The goal of regression is to find a mathematical
equation that best describes the relationship between the
variables, allowing us to make predictions about the dependent
variable based on values of the independent variables.
What is classification?
Classification is a machine learning technique used to predict a
categorical label (or class) based on a set of input features. In
other words, it's a way of sorting items into one of several
predefined categories based on their characteristics.
38 | Heemali Chaudhari
Give me a list of Python Libraries and their uses?
39 | Heemali Chaudhari
What is the use of Matplotlib in data visualization?
Matplotlib is a data visualization library in Python that
provides a collection of functions and methods to create
static, animated, and interactive visualizations. It provides a
high-level interface for drawing attractive and informative
statistical graphics.
40 | Heemali Chaudhari
What is Plotly and when would you use it for data
visualization?
Plotly is an open-source data visualization library for
Python, R, and JavaScript. It provides a high-level
interface for creating interactive and animated
visualizations in a web browser. Unlike Matplotlib, which
generates static visualizations, Plotly creates interactive
visualizations that can be interacted with and explored by
the user.
41 | Heemali Chaudhari
What is the use of the Scikit-learn library in machine
learning?
Scikit-learn is a machine learning library for Python that
provides simple and efficient tools for data mining and
data analysis. It contains a variety of algorithms for
classification, regression, clustering, dimensionality
reduction, and model selection, among others. The library
provides a unified interface to these algorithms, making it
easy to switch between different algorithms and to
compare the results.
42 | Heemali Chaudhari
Can you explain how to perform feature selection using
the scikit-learn library?
Feature selection is the process of selecting a subset of
relevant features from a larger set of features for use in a
machine learning model. In scikit-learn, there are several
methods for feature selection, including univariate feature
selection, recursive feature elimination, and lasso
regularization. To perform feature selection, you can use
the SelectKBest or SelectFromModel classes, which can be
applied to the data before training a machine learning
model.
43 | Heemali Chaudhari
Can you explain how to perform sentiment analysis with the
NLTK library?
Sentiment analysis is the process of determining the sentiment or
emotion expressed in a piece of text, such as a tweet or a
customer review. In NLTK, sentiment analysis can be performed
using various techniques, including bag-of-words models, n-
gram models, and deep learning models. To perform sentiment
analysis, you can start by preprocessing the text data, such as
removing stop words and stemming the words. Then, you can
use the TextBlob or Vader SentimentIntensityAnalyzer libraries
to classify the sentiment of each text.
44 | Heemali Chaudhari
What is the difference between static and dynamic typing
in Python, and how does it affect library usage?
Static typing refers to the practice of declaring the data
type of a variable before its use. This means that the type
of a variable is determined at compile-time and cannot
change during runtime.
45 | Heemali Chaudhari
Found this helpful?
such resources : )