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 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:

  • Python is slower than languages like Java and C++, according to studies. A custom
  • runtime is one way to make Python faster, though.
  • Python 2 and Python 3 cannot be used together.
  • 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 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.


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