WHAT ARE SOME OF THE MOST COMMON LIBRARIES IN PYTHON?
The most popular Python data analysis libraries are as follows: Pandas \NumPy \sciPy \TensorFlow \SciKit \seaborn \Matplotlib
HOW WOULD YOU FIND DUPLICATE VALUES IN A DATASET FOR A VARIABLE IN PYTHON?
With the Pandas duplicated() method, you may search for duplicates. This will give you a boolean series that is TRUE only for elements that are unique. DataFrame.duplicated(subset=None,keep=’last’) Keep in this case chooses what to deal with duplicates. You may utilise: First – The first value is regarded as unique, while the others are duplicates. The last value is regarded as unique, whereas the other values are seen as duplicates. False – Treats identical values as duplicates.
WHAT IS THE USE OF A LAMBDA FUNCTION IN PYTHON?
The lambda function, sometimes referred to as an “anonymous function,” is identical to a regular function but is not specified with the keyword. The keyword serves to define them. Similar to regular functions, lambda functions are limited to a single line of expression and accept many parameters.
WHAT’S THE DIFFERENCE BETWEEN / AND // IN PYTHON?
They are both division operators: / and //. /, on the other hand, performs float division by splitting the first operand in half. The value is returned in decimal form. // divides the first operand by the second to compute the floor, but returns the result in natural number form.
/ example: 9 / 2 returns 4.5
// example: 9 / 2 returns 4
WHAT’S THE DIFFERENCE BETWEEN MUTABLE AND IMMUTABLE OBJECTS?
If or not an object’s value can change, it is mutable or immutable in Python. These values can be altered by mutable objects, but not by immutable objects. Lists, sets, dictionaries, and byte arrays are some examples of mutable data types. Immutable data types include strings, frozensets, tuples, and numeric data types (boolean, float, etc.).
WHAT ARE SOME OF THE LIMITATIONS OF PYTHON?
Python has some significant limitations, such as:
a) Python is slower than languages like Java and C++, according to studies. A custom
b) runtime is one way to make Python faster, though.
c) Python 2 and Python 3 cannot be used together.
d) Python is excellent for desktop and server apps, but it is less strong for mobile development.
Memory use – Python is not recommended for applications that require lots of memory.
IS PYTHON A LANGUAGE THAT EMPHASISES OBJECTS?
Describe the term “object-oriented programming.” Certainly, Python may contain the codes within the objects because it is an object-oriented programming language. The property enables the object to include both the data and the method as a single entity.
WHAT IS A PYTHON MODULE? HOW IS IT DIFFERENT FROM LIBRARIES?
A module is a single file (or set of files) that contains variables, definitions, and functions that are intended to carry out specific duties. The file has a.py extension. It just needs to be imported once and may be done at any moment throughout a session. There are two ways to import a Python module: import and from module name import. The ability to do a range of activities without having to write the code is made possible by libraries, which are collections of reusable programming functionality. There is no defined context for a Python library. It vaguely alludes to a group of modules. You can utilise these codes by importing the library and invoking a method (or attribute) from it with a period (.)
WHAT ARE COMPOUND DATA TYPES AND DATA STRUCTURES?
Compound data types are created by combining simple, primitive, and basic data types. Python data structures let us store numerous observations. They consist of dictionaries, sets, tuples, and lists.
WHAT IS TUPLE UNPACKING? WHY IS IT IMPORTANT?
A tuple can be broken down into its component parts in the following ways: We have the tuple x = (600, 350) The following two new variables can be assigned to this tuple: a,b = x The output of printing letters a and b is now: print(a) = 600 and print(b) = 350. To separate each value one at a time, use the triple unpacking method. The output of machine learning algorithms typically comes in the form of a tuple. The unpacking feature of tuples can be used if, for example, x = (avg, max) and we want to use these values individually for additional analysis.
WHAT ARE GENERATORS AND DECORATORS?
A function that returns an iterable or object that can be iterated, or taken one value at a time, is called a generator. We can change or modify the classes, methods, and functions with the aid of decorators.
WHAT IS THE DIFFERENCE BETWEEN ‘IS AND ‘==’ ?
‘==’ checks for equality between the variables, and ‘is’ checks for the identity of the variables.
WHAT IS THE DIFFERENCE BETWEEN INDEXING AND SLICING?
Slicing obtains a series of elements, whereas indexing extracts or looks up one or more specific values in a data structure.
WHAT IS THE DIFFERENCE BETWEEN DEL(), CLEAR(), REMOVE(), AND POP()?
With respect to the position of the value, del() deletes the. The removed value is not returned. Moreover, it reduces the index by one value, moving it to the right. Moreover, the whole data structure can be deleted using it.
List clearing with clear().
If you know which specific value to delete, you can use the function remove() because it deletes with respect to the value.
pop(): by default returns the value that was deleted together with the last element that was removed. It is frequently employed for creating referencing. It makes sense to save this erased return value to a variable for later usage.
WHAT IS PYTHONPATH?
When a module is imported, this environment variable is used. When a module is imported, PYTHONPATH is also checked to see if the imported modules are present in any other directories. It is used by the interpreter to choose which module to load.
IS INDENTATION REQUIRED IN PYTHON?
For Python, indentation is necessary. It designates a section of code. The code for all loops, classes, functions, and other structures is contained in an indented block. Typically, four space characters are used. If your code is not indented properly, it will not run correctly and will also produce errors.
HOW DO PASS, CONTINUE, AND BREAK OPERATE?
Break: When a condition is met, the loop can be broken, and control is then passed on to the following statement.
Continue: Permits skipping a portion of a loop when a certain condition is satisfied and control is returned to the loop’s beginning.
Pass: Used when you want to skip the execution of a block of code but you need it syntactically. In essence, this is a null operation. When this is used, nothing occurs.
WHAT IS PICKLING AND UNPICKLING?
Pickling is the process of taking any Python object and turning it into a string representation and dumping it into a file using the dump function. Unpickling is the process of obtaining the original Python objects from the stored string representation.
HOW WILL YOU CAPITALISE THE FIRST LETTER OF THE STRING?
The capitalise() method in Python capitalises the first character in a string. It returns the original string if the string already has a capital letter at the beginning.
WHAT IS THE DIFFERENCE BETWEEN LISTS AND TUPLES IN PYTHON?
Tuples are enclosed in parenthesis, and lists are enclosed in square brackets.
Lists are changeable, which implies they can be changed after being formed, as opposed to immutable objects. Tuples cannot be changed since they are immutable.
Operations: Compared to tuples, lists offer more functions, such as sorting and insert and pop operations.
Tuples are immutable, thus they utilise less memory, which makes them faster in terms of size.
WHAT ARE THE KEY FEATURES OF PYTHON?
Python is an interpreted, high-level language with simple syntax, dynamic typing, automatic memory management, and strong library support, making it ideal for data analysis and automation.
WHAT IS THE DIFFERENCE BETWEEN A LIST AND A TUPLE?
Lists are mutable (can be changed), while tuples are immutable. Tuples are faster and safer for fixed data.
EXPLAIN WHAT A DICTIONARY IS.
A dictionary stores data in key–value pairs, allowing fast lookups using unique keys.
WHAT IS LIST COMPREHENSION?
It’s a concise way to create lists using a single line of code with an expression and optional conditions.
DIFFERENCE BETWEEN == AND IS?
== checks value equality, while is checks whether both variables refer to the same object in memory.
WHAT ARE PYTHON DECORATORS?
Decorators are functions that modify the behavior of another function without changing its code.
WHAT IS A LAMBDA FUNCTION?
A lambda function is an anonymous, one-line function used for short operations.
EXPLAIN EXCEPTION HANDLING IN PYTHON.
Exception handling uses try, except, else, and finally blocks to handle runtime errors gracefully.
WHAT IS THE GLOBAL INTERPRETER LOCK (GIL)?
The GIL ensures only one thread executes Python bytecode at a time, which affects multi-threading performance.
DIFFERENCE BETWEEN DEEP COPY AND SHALLOW COPY?
A shallow copy copies references, while a deep copy duplicates all nested objects independently.
WHAT ARE GENERATORS?
Generators produce values one at a time using yield, saving memory for large datasets.
HOW DOES PYTHON MANAGE MEMORY?
Python uses automatic memory allocation and garbage collection to manage unused objects.
WHAT IS INIT IN PYTHON?
__init__ is a constructor method used to initialize object attributes when an object is created.
DIFFERENCE BETWEEN *ARGS AND KWARGS?
*args handles variable positional arguments, while **kwargs handles variable keyword arguments.
WHY IS PYTHON POPULAR IN DATA SCIENCE?
Because of libraries like NumPy, pandas, matplotlib, and its easy integration with machine learning tools.
WHAT IS PYTHON AND WHERE IS IT COMMONLY USED?
Python is a high-level, interpreted, object-oriented language known for readability. It’s widely used in web development, data science, automation, AI/ML, scripting, and backend development.
WHAT IS DYNAMIC TYPING IN PYTHON?
Variable types are decided at runtime. We don’t need to declare data types explicitly.
WHAT ARE PYTHON’S BUILT-IN DATA TYPES?
int, float, complex, string, list, tuple, set, dictionary, and boolean.
WHAT IS INDENTATION AND WHY IS IT IMPORTANT?
Indentation defines code blocks in Python. Incorrect indentation causes syntax errors.
WHAT ARE PYTHON LOOPS?
for loops iterate over sequences; while loops run until a condition becomes false.
WHAT IS A MODULE?
A Python file containing functions and variables that can be imported into another program.
WHAT IS ENCAPSULATION?
Binding data and methods together while restricting direct access to variables.
DIFFERENCE BETWEEN APPEND() AND EXTEND()?
append() adds one element; extend() adds multiple elements to a list.
WHY SHOULD A COMPANY CHOOSE PYTHON?
Rapid development, scalability, strong libraries, cost-effectiveness, and wide industry adoption.